@@ -31,10 +31,9 @@ public class ServiceResponseException extends RuntimeException {
31
31
private static final long serialVersionUID = 1L ;
32
32
33
33
/** Potential error message keys. */
34
- private static final String MESSAGE_ERROR = "error" ;
35
- private static final String MESSAGE_ERROR_2 = "error_message" ;
36
- private static final String MESSAGE_ERROR_3 = "message" ;
37
- private static final String [] ERROR_KEYS = { MESSAGE_ERROR , MESSAGE_ERROR_2 , MESSAGE_ERROR_3 };
34
+ private static final String ERRORS_KEY = "errors" ;
35
+ private static final String MESSAGE_STRING = "message" ;
36
+ private static final String ERROR_STRING = "error" ;
38
37
39
38
private static final Type debuggingInfoType = new TypeToken <Map <String , Object >>() { }.getType ();
40
39
@@ -59,11 +58,13 @@ public ServiceResponseException(int statusCode, Response response) {
59
58
String responseString = ResponseUtils .getString (response );
60
59
try {
61
60
final JsonObject jsonObject = ResponseUtils .getJsonObject (responseString );
62
- for (String errorKey : ERROR_KEYS ) {
63
- if (jsonObject .has (errorKey )) {
64
- this .message = jsonObject .remove (errorKey ).getAsString ();
65
- break ;
66
- }
61
+ if (jsonObject .has (ERRORS_KEY )) {
62
+ this .message = jsonObject .remove (ERRORS_KEY ).getAsJsonArray ().get (0 ).getAsJsonObject ().remove (MESSAGE_STRING )
63
+ .getAsString ();
64
+ } else if (jsonObject .has (ERROR_STRING )) {
65
+ this .message = jsonObject .remove (ERROR_STRING ).getAsString ();
66
+ } else if (jsonObject .has (MESSAGE_STRING )) {
67
+ this .message = jsonObject .remove (MESSAGE_STRING ).getAsString ();
67
68
}
68
69
this .debuggingInfo = GsonSingleton .getGson ().fromJson (jsonObject , debuggingInfoType );
69
70
} catch (final Exception e ) {
0 commit comments