Skip to content

Commit

Permalink
[FLINK-9173][REST] Improve client error message for parsing failures
Browse files Browse the repository at this point in the history
- print parsing exception for expected type, not error
- add toString implemented to JsonResponse
  • Loading branch information
zentol committed Apr 16, 2018
1 parent 185b904 commit e95fa5a
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ private static <P extends ResponseBody> CompletableFuture<P> parseResponse(JsonR
try {
P response = objectMapper.readValue(jsonParser, responseType);
responseFuture.complete(response);
} catch (IOException ioe) {
} catch (IOException originalException) {
// the received response did not matched the expected response type

// lets see if it is an ErrorResponse instead
Expand All @@ -231,7 +231,7 @@ private static <P extends ResponseBody> CompletableFuture<P> parseResponse(JsonR
responseFuture.completeExceptionally(
new RestClientException(
"Response was neither of the expected type(" + responseType + ") nor an error.",
jpe2,
originalException,
rawResponse.getHttpResponseStatus()));
}
}
Expand Down Expand Up @@ -328,5 +328,13 @@ public JsonNode getJson() {
public HttpResponseStatus getHttpResponseStatus() {
return httpResponseStatus;
}

@Override
public String toString() {
return "JsonResponse{" +
"json=" + json +
", httpResponseStatus=" + httpResponseStatus +
'}';
}
}
}

0 comments on commit e95fa5a

Please sign in to comment.