@@ -89,6 +89,7 @@ public void onHeaders(SdkHttpResponse response) {
8989 log .debug ("received response headers: " + sdkResponse .headers ());
9090 this .statusCode = sdkResponse .statusCode ();
9191 if (statusCode < HttpStatus .SC_OK || statusCode > HttpStatus .SC_MULTIPLE_CHOICES ) {
92+ log .error ("Received error from remote service with status code {}, response headers: {}" , statusCode , sdkResponse .headers ());
9293 handleThrottlingInHeader (sdkResponse );
9394 // add more handling here for other exceptions in headers
9495 }
@@ -101,7 +102,7 @@ public void onStream(Publisher<ByteBuffer> stream) {
101102
102103 @ Override
103104 public void onError (Throwable error ) {
104- log .error (error .getMessage (), error );
105+ log .error ("Received error from remote service: {}" , error .getMessage (), error );
105106 RestStatus status = (statusCode == null ) ? RestStatus .INTERNAL_SERVER_ERROR : RestStatus .fromCode (statusCode );
106107 String errorMessage = "Error communicating with remote model: " + error .getMessage ();
107108 actionListener .onFailure (new OpenSearchStatusException (errorMessage , status ));
@@ -173,6 +174,7 @@ private void response() {
173174 String body = responseBody .toString ();
174175
175176 if (exceptionHolder .get () != null ) {
177+ log .error ("Remote server returned exception with status code: {} and body: {}" , statusCode , body );
176178 actionListener .onFailure (exceptionHolder .get ());
177179 return ;
178180 }
@@ -184,7 +186,7 @@ private void response() {
184186 }
185187
186188 if (statusCode < HttpStatus .SC_OK || statusCode > HttpStatus .SC_MULTIPLE_CHOICES ) {
187- log .error ("Remote server returned error code: {}" , statusCode );
189+ log .error ("Remote service returned error code: {} with body: {} " , statusCode , body );
188190 actionListener .onFailure (new OpenSearchStatusException (REMOTE_SERVICE_ERROR + body , RestStatus .fromCode (statusCode )));
189191 return ;
190192 }
0 commit comments