@@ -89,6 +89,7 @@ public void onHeaders(SdkHttpResponse response) {
89
89
log .debug ("received response headers: " + sdkResponse .headers ());
90
90
this .statusCode = sdkResponse .statusCode ();
91
91
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 ());
92
93
handleThrottlingInHeader (sdkResponse );
93
94
// add more handling here for other exceptions in headers
94
95
}
@@ -101,7 +102,7 @@ public void onStream(Publisher<ByteBuffer> stream) {
101
102
102
103
@ Override
103
104
public void onError (Throwable error ) {
104
- log .error (error .getMessage (), error );
105
+ log .error ("Received error from remote service: {}" , error .getMessage (), error );
105
106
RestStatus status = (statusCode == null ) ? RestStatus .INTERNAL_SERVER_ERROR : RestStatus .fromCode (statusCode );
106
107
String errorMessage = "Error communicating with remote model: " + error .getMessage ();
107
108
actionListener .onFailure (new OpenSearchStatusException (errorMessage , status ));
@@ -173,6 +174,7 @@ private void response() {
173
174
String body = responseBody .toString ();
174
175
175
176
if (exceptionHolder .get () != null ) {
177
+ log .error ("Remote server returned exception with status code: {} and body: {}" , statusCode , body );
176
178
actionListener .onFailure (exceptionHolder .get ());
177
179
return ;
178
180
}
@@ -184,7 +186,7 @@ private void response() {
184
186
}
185
187
186
188
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 );
188
190
actionListener .onFailure (new OpenSearchStatusException (REMOTE_SERVICE_ERROR + body , RestStatus .fromCode (statusCode )));
189
191
return ;
190
192
}
0 commit comments