Register status handler exceptions in observations
Prior to this commit, `RestClientException` thrown by status handlers would not be registered as observation errors. This commit ensures that such exceptions are first caught, registered in the observation and rethrown as expected. Closes gh-32575
This commit is contained in:
@@ -228,13 +228,13 @@ final class DefaultRestClient implements RestClient {
|
||||
}
|
||||
throw unknownContentTypeException;
|
||||
}
|
||||
catch (UncheckedIOException | IOException | HttpMessageNotReadableException ex) {
|
||||
catch (UncheckedIOException | IOException | HttpMessageNotReadableException exc) {
|
||||
Throwable cause;
|
||||
if (ex instanceof UncheckedIOException uncheckedIOException) {
|
||||
if (exc instanceof UncheckedIOException uncheckedIOException) {
|
||||
cause = uncheckedIOException.getCause();
|
||||
}
|
||||
else {
|
||||
cause = ex;
|
||||
cause = exc;
|
||||
}
|
||||
RestClientException restClientException = new RestClientException("Error while extracting response for type [" +
|
||||
ResolvableType.forType(bodyType) + "] and content type [" + contentType + "]", cause);
|
||||
@@ -243,6 +243,12 @@ final class DefaultRestClient implements RestClient {
|
||||
}
|
||||
throw restClientException;
|
||||
}
|
||||
catch (RestClientException restClientException) {
|
||||
if (observation != null) {
|
||||
observation.error(restClientException);
|
||||
}
|
||||
throw restClientException;
|
||||
}
|
||||
finally {
|
||||
if (observation != null) {
|
||||
observation.stop();
|
||||
|
||||
Reference in New Issue
Block a user