Skip to content

Commit

Permalink
Merge pull request #1476 from data-integrations/CDAP-21093
Browse files Browse the repository at this point in the history
[CDAP-21093] Add errorCodeType, errorCode & supportedDocURL in exception
  • Loading branch information
itsankit-google authored Dec 16, 2024
2 parents b986f30 + 864a42f commit 228ece3
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.google.common.base.Throwables;
import io.cdap.cdap.api.exception.ErrorCategory;
import io.cdap.cdap.api.exception.ErrorCategory.ErrorCategoryEnum;
import io.cdap.cdap.api.exception.ErrorCodeType;
import io.cdap.cdap.api.exception.ErrorType;
import io.cdap.cdap.api.exception.ErrorUtils;
import io.cdap.cdap.api.exception.ProgramFailureException;
Expand Down Expand Up @@ -78,12 +79,13 @@ private ProgramFailureException getProgramFailureException(HttpResponseException
String errorMessageFormat = "Error occurred in the phase: '%s'. Error message: %s";

String errorMessage = e.getMessage();
String externalDocumentationLink = null;
if (e instanceof GoogleJsonResponseException) {
GoogleJsonResponseException exception = (GoogleJsonResponseException) e;
errorMessage = exception.getDetails() != null ? exception.getDetails().getMessage() :
exception.getMessage();

String externalDocumentationLink = getExternalDocumentationLink();
externalDocumentationLink = getExternalDocumentationLink();
if (!Strings.isNullOrEmpty(externalDocumentationLink)) {

if (!errorReason.endsWith(".")) {
Expand All @@ -96,7 +98,8 @@ private ProgramFailureException getProgramFailureException(HttpResponseException

return ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategoryEnum.PLUGIN),
errorReason, String.format(errorMessageFormat, errorContext.getPhase(), errorMessage),
pair.getErrorType(), true, e);
pair.getErrorType(), true, ErrorCodeType.HTTP, statusCode.toString(),
externalDocumentationLink, e);
}


Expand Down

0 comments on commit 228ece3

Please sign in to comment.