From 3ee5cc4256aee9eee8a7b12f3454d63fc11beadf Mon Sep 17 00:00:00 2001 From: meywood <105049338+meywood@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:02:54 +0000 Subject: [PATCH 1/2] issues/260 - Fixed issue with CasperClientException not displaying data message. --- .../com/casper/sdk/exception/CasperClientException.java | 8 ++++---- .../java/com/casper/sdk/service/CasperServiceTests.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/casper/sdk/exception/CasperClientException.java b/src/main/java/com/casper/sdk/exception/CasperClientException.java index 20204ee3a..7e8730fdc 100644 --- a/src/main/java/com/casper/sdk/exception/CasperClientException.java +++ b/src/main/java/com/casper/sdk/exception/CasperClientException.java @@ -9,15 +9,15 @@ */ public class CasperClientException extends RuntimeException { - public CasperClientException(CasperClientErrorData error) { - super(String.format("%s (code: %d)", error.getMessage(), error.getCode())); + public CasperClientException(final CasperClientErrorData error) { + super(String.format("%s (code: %d) %s", error.getMessage(), error.getCode(), error.getData() != null ? error.getData() : "")); } - public CasperClientException(String message, Throwable cause) { + public CasperClientException(final String message, final Throwable cause) { super(message, cause); } - public CasperClientException(String message) { + public CasperClientException(final String message) { super(message); } } diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTests.java b/src/test/java/com/casper/sdk/service/CasperServiceTests.java index 0e3b6db71..8f59bf691 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTests.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTests.java @@ -488,7 +488,7 @@ void getCasperClientExceptionExceptionBlockNotKnown() { .withBody("$.params.deploy_hash", "abc") .thenDispatch(getClass().getResource("/deploy-samples/info_get_deploy_error.json")); - final String expectedMessage = "Invalid params (code: -32602)"; + final String expectedMessage = "Invalid params (code: -32602) Failed to parse 'params' field: could not convert slice to arrayt "; final CasperClientException casperClientException = assertThrows(CasperClientException.class, () -> casperServiceMock.getDeploy("abc")); From 766457088d802e06814148e2d964ea80fdf80f4c Mon Sep 17 00:00:00 2001 From: meywood <105049338+meywood@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:05:07 +0000 Subject: [PATCH 2/2] issues/260 - Fixed issue with CasperClientException not displaying data message. --- .../java/com/casper/sdk/exception/CasperClientException.java | 2 +- src/test/java/com/casper/sdk/service/CasperServiceTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/casper/sdk/exception/CasperClientException.java b/src/main/java/com/casper/sdk/exception/CasperClientException.java index 7e8730fdc..309f2f679 100644 --- a/src/main/java/com/casper/sdk/exception/CasperClientException.java +++ b/src/main/java/com/casper/sdk/exception/CasperClientException.java @@ -10,7 +10,7 @@ public class CasperClientException extends RuntimeException { public CasperClientException(final CasperClientErrorData error) { - super(String.format("%s (code: %d) %s", error.getMessage(), error.getCode(), error.getData() != null ? error.getData() : "")); + super(String.format("%s (code: %d)%s", error.getMessage(), error.getCode(), error.getData() != null ? " " + error.getData() : "")); } public CasperClientException(final String message, final Throwable cause) { diff --git a/src/test/java/com/casper/sdk/service/CasperServiceTests.java b/src/test/java/com/casper/sdk/service/CasperServiceTests.java index 8f59bf691..e9018a9e8 100644 --- a/src/test/java/com/casper/sdk/service/CasperServiceTests.java +++ b/src/test/java/com/casper/sdk/service/CasperServiceTests.java @@ -488,7 +488,7 @@ void getCasperClientExceptionExceptionBlockNotKnown() { .withBody("$.params.deploy_hash", "abc") .thenDispatch(getClass().getResource("/deploy-samples/info_get_deploy_error.json")); - final String expectedMessage = "Invalid params (code: -32602) Failed to parse 'params' field: could not convert slice to arrayt "; + final String expectedMessage = "Invalid params (code: -32602) Failed to parse 'params' field: could not convert slice to array"; final CasperClientException casperClientException = assertThrows(CasperClientException.class, () -> casperServiceMock.getDeploy("abc"));