[FLINK-9173][REST] Improve client error message for parsing failures

- print parsing exception for expected type, not error
- add toString implemented to JsonResponse


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/e95fa5a4
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/e95fa5a4
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/e95fa5a4

Branch: refs/heads/master
Commit: e95fa5a4a03fce74a76acbbbb29395c8a5f69276
Parents: 185b904
Author: zentol <ches...@apache.org>
Authored: Mon Apr 16 10:31:52 2018 +0200
Committer: zentol <ches...@apache.org>
Committed: Mon Apr 16 21:17:53 2018 +0200

----------------------------------------------------------------------
 .../java/org/apache/flink/runtime/rest/RestClient.java  | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/e95fa5a4/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java
----------------------------------------------------------------------
diff --git 
a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java 
b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java
index 6319634..df97f20 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/rest/RestClient.java
@@ -217,7 +217,7 @@ public class RestClient {
                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
@@ -231,7 +231,7 @@ public class RestClient {
                                responseFuture.completeExceptionally(
                                        new RestClientException(
                                                "Response was neither of the 
expected type(" + responseType + ") nor an error.",
-                                               jpe2,
+                                               originalException,
                                                
rawResponse.getHttpResponseStatus()));
                        }
                }
@@ -328,5 +328,13 @@ public class RestClient {
                public HttpResponseStatus getHttpResponseStatus() {
                        return httpResponseStatus;
                }
+
+               @Override
+               public String toString() {
+                       return "JsonResponse{" +
+                               "json=" + json +
+                               ", httpResponseStatus=" + httpResponseStatus +
+                               '}';
+               }
        }
 }

Reply via email to