Skip to content

Commit

Permalink
[feat]: [CDS-77663]: Added Error handling for create flow for gitlab …
Browse files Browse the repository at this point in the history
…and bitbucket (#52957)

* [feat]: [CDS-77663]: Added Error handling for create flow for gitlab and bitbucket

* [feat]: [CDS-77663]: Added Error handling for create flow for gitlab and bitbucket
  • Loading branch information
adivishy1 authored Sep 15, 2023
1 parent b587dff commit 2aaec1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import static io.harness.annotations.dev.HarnessTeam.PL;
import static io.harness.gitsync.common.scmerrorhandling.handlers.bitbucketcloud.ScmErrorExplanations.INVALID_CONNECTOR_CREDS;
import static io.harness.gitsync.common.scmerrorhandling.handlers.bitbucketcloud.ScmErrorExplanations.OAUTH_ACCESS_DENIED;
import static io.harness.gitsync.common.scmerrorhandling.handlers.bitbucketcloud.ScmErrorHints.INVALID_CREDENTIALS;
import static io.harness.gitsync.common.scmerrorhandling.handlers.bitbucketcloud.ScmErrorHints.REPO_NOT_FOUND;

Expand Down Expand Up @@ -42,7 +43,8 @@ public void handleError(int statusCode, String errorMessage, ErrorMetadata error
case 403:
throw NestedExceptionUtils.hintWithExplanationException(
ErrorMessageFormatter.formatMessage(INVALID_CREDENTIALS, errorMetadata),
ErrorMessageFormatter.formatMessage(CREATE_FILE_REQUEST_FAILURE + INVALID_CONNECTOR_CREDS, errorMetadata),
ErrorMessageFormatter.formatMessage(
CREATE_FILE_REQUEST_FAILURE + INVALID_CONNECTOR_CREDS + OAUTH_ACCESS_DENIED, errorMetadata),
new ScmUnauthorizedException(errorMessage));
case 400:
throw NestedExceptionUtils.hintWithExplanationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
@OwnedBy(PIPELINE)
public class GitlabCreateFileScmApiErrorHandler implements ScmApiErrorHandler {
public static final String CREATE_FILE_WITH_INVALID_CREDS =
"The requested file<FILEPATH> couldn't be created in Gitlab. " + ScmErrorExplanations.INVALID_CONNECTOR_CREDS;
"The requested file<FILEPATH> couldn't be created in Gitlab. " + ScmErrorExplanations.INVALID_CONNECTOR_CREDS
+ "\n- " + ScmErrorExplanations.OAUTH_ACCESS_DENIED;
public static final String CREATE_FILE_NOT_FOUND_ERROR_HINT = "Please check the following:\n"
+ "1. If requested Gitlab repository<REPO> exists or not.\n"
+ "2. If requested branch<BRANCH> exists or not.\n"
Expand Down

0 comments on commit 2aaec1d

Please sign in to comment.