@@ -78,11 +78,11 @@ private T parseResponse(@Nonnull final ClassicHttpResponse response) throws E {
7878 throw exceptionConstructor .apply ("Response was empty." , null );
7979 }
8080 val content = getContent (responseEntity );
81- log .debug ("Parsing response from JSON response : {}" , content );
81+ log .debug ("Deserializing JSON response to type {} : {}" , responseType . getSimpleName () , content );
8282 try {
8383 return objectMapper .readValue (content , responseType );
8484 } catch (final JsonProcessingException e ) {
85- log .error ("Failed to parse the following response: {}" , content );
85+ log .error ("Failed to deserialize the response to type : {}" , responseType . getSimpleName (), e );
8686 throw exceptionConstructor .apply ("Failed to parse response" , e );
8787 }
8888 }
@@ -103,10 +103,11 @@ private String getContent(@Nonnull final HttpEntity entity) {
103103 */
104104 @ SuppressWarnings ("PMD.CloseResource" )
105105 public void buildExceptionAndThrow (@ Nonnull final ClassicHttpResponse response ) throws E {
106+ val errorCode = response .getCode ();
106107 val exception =
107108 exceptionConstructor .apply (
108109 "Request failed with status %s %s"
109- .formatted (response . getCode () , response .getReasonPhrase ()),
110+ .formatted (errorCode , response .getReasonPhrase ()),
110111 null );
111112 val entity = response .getEntity ();
112113 if (entity == null ) {
@@ -122,7 +123,8 @@ public void buildExceptionAndThrow(@Nonnull final ClassicHttpResponse response)
122123 throw exception ;
123124 }
124125
125- log .error ("The service responded with an HTTP error and the following content: {}" , content );
126+ log .error ("The service responded with HTTP error code {}" , errorCode );
127+ log .debug ("The service responded with HTTP error code {} and content: {}" , errorCode , content );
126128 val contentType = ContentType .parse (entity .getContentType ());
127129 if (!ContentType .APPLICATION_JSON .isSameMimeType (contentType )) {
128130 throw exception ;
0 commit comments