From f70fc084be62b332a8156d43b2642842b776aab2 Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Mon, 25 Sep 2017 20:48:36 +0200 Subject: [PATCH] Override toString() on ErrorResponse Partially reverts last commit that added first error message to exception without checking for presence of such. --- .../de/stklcode/jvault/connector/HTTPVaultConnector.java | 2 +- .../jvault/connector/model/response/ErrorResponse.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java b/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java index fa7176c..af3038a 100644 --- a/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java +++ b/src/main/java/de/stklcode/jvault/connector/HTTPVaultConnector.java @@ -849,7 +849,7 @@ public class HTTPVaultConnector implements VaultConnector { if (!er.getErrors().isEmpty() && er.getErrors().get(0).equals("permission denied")) throw new PermissionDeniedException(); throw new InvalidResponseException(Error.RESPONSE_CODE, - response.getStatusLine().getStatusCode(), er.getErrors().get(0)); + response.getStatusLine().getStatusCode(), er.toString()); } catch (IOException ignored) { // Exception ignored. } diff --git a/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java b/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java index 5612f9c..ed0f766 100644 --- a/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java +++ b/src/main/java/de/stklcode/jvault/connector/model/response/ErrorResponse.java @@ -38,4 +38,13 @@ public final class ErrorResponse implements VaultResponse { public List getErrors() { return errors; } + + @Override + public String toString() { + if (errors == null || errors.isEmpty()) { + return "error response"; + } else { + return errors.get(0); + } + } }