@@ -1098,22 +1098,29 @@ public <T> ApiResponse<T> invokeAPIWithReturnMap(
10981098 }
10991099
11001100 if (returnTypeMap .keySet ().contains (statusCode )){
1101-
1101+
11021102 if (response .getStatusInfo ().getFamily () != Status .Family .SUCCESSFUL ){
11031103 ClientErrorResponse clientErrorResponse = deserialize (response , new GenericType <ClientErrorResponse >() {});
11041104
11051105 String reason = "" ;
1106- if (!clientErrorResponse .getErrors ().isEmpty () && clientErrorResponse .getErrors ().get (0 ).getDetail () != null ) {
1107- List <Error > errors = clientErrorResponse .getErrors ();
1108- reason = errors .get (0 ).getDetail ();
1109-
1110- for (int i = 1 ; i < errors .size (); i ++) {
1111- if (errors .get (i ).getDetail () != null )
1112- reason = reason + " ||| " + errors .get (i ).getDetail ();
1106+ if (clientErrorResponse != null && !clientErrorResponse .getErrors ().isEmpty () && clientErrorResponse .getErrors ().get (0 ).getDetail () != null ) {
1107+ List <Error > errors = clientErrorResponse .getErrors ();
1108+ reason = errors .get (0 ).getDetail ();
1109+
1110+ for (int i = 1 ; i < errors .size (); i ++) {
1111+ if (errors .get (i ).getDetail () != null )
1112+ reason = reason + " ||| " + errors .get (i ).getDetail ();
1113+ }
1114+ }
1115+
1116+ if (clientErrorResponse == null && responseHeaders != null ) {
1117+ Error error = new Error ();
1118+ for (Entry <String , List <String >> entry : responseHeaders .entrySet ()){
1119+ if ("x-factset-api-request-key" .equals (entry .getKey ().toLowerCase ())) {
1120+ error .setId (entry .getValue ().toString ());
11131121 }
1114- }
1115- if (reason .isEmpty ()) {
1116- reason = "API error" ;
1122+ }
1123+ clientErrorResponse = new ClientErrorResponse ().addErrorsItem (error );
11171124 }
11181125
11191126 throw new ApiException (response .getStatus (), "error" , responseHeaders , reason , clientErrorResponse );
0 commit comments