@@ -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