Skip to content

Commit c5f4d69

Browse files
Merge pull request #1480 from data-integrations/PLUGIN-1807-4
[PLUGINk-1807] Add more detailed error in error message
2 parents 489de36 + 2d8213f commit c5f4d69

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,14 @@ public ProgramFailureException getExceptionDetails(Exception e, ErrorContext err
7474
private ProgramFailureException getProgramFailureException(HttpResponseException e, ErrorContext errorContext) {
7575
Integer statusCode = e.getStatusCode();
7676
ErrorUtils.ActionErrorPair pair = ErrorUtils.getActionErrorByStatusCode(statusCode);
77-
String errorReason = String.format("%s %s %s", e.getStatusCode(), e.getStatusMessage(),
77+
String errorReason = String.format("%s %s. %s", e.getStatusCode(), e.getStatusMessage(),
7878
pair.getCorrectiveAction());
7979
String errorMessageFormat = "Error occurred in the phase: '%s'. Error message: %s";
8080

8181
String errorMessage = e.getMessage();
8282
String externalDocumentationLink = null;
8383
if (e instanceof GoogleJsonResponseException) {
84-
GoogleJsonResponseException exception = (GoogleJsonResponseException) e;
85-
errorMessage = exception.getDetails() != null ? exception.getDetails().getMessage() :
86-
exception.getMessage();
84+
errorMessage = getErrorMessage((GoogleJsonResponseException) e);
8785

8886
externalDocumentationLink = getExternalDocumentationLink();
8987
if (!Strings.isNullOrEmpty(externalDocumentationLink)) {
@@ -102,6 +100,17 @@ private ProgramFailureException getProgramFailureException(HttpResponseException
102100
externalDocumentationLink, e);
103101
}
104102

103+
private String getErrorMessage(GoogleJsonResponseException exception) {
104+
if (exception.getDetails() != null) {
105+
try {
106+
return exception.getDetails().toPrettyString();
107+
} catch (IOException e) {
108+
return exception.getDetails().toString();
109+
}
110+
}
111+
return exception.getMessage();
112+
}
113+
105114

106115
/**
107116
* Get a ProgramFailureException with the given error

0 commit comments

Comments
 (0)