diff --git a/reddio-java/pom.xml b/reddio-java/pom.xml
index 8b78e78..de503a2 100644
--- a/reddio-java/pom.xml
+++ b/reddio-java/pom.xml
@@ -56,7 +56,7 @@
UTF-8
1.8
1.8
- 0.0.54-SNAPSHOT
+ 0.0.54
true
diff --git a/reddio-java/reddio-api/src/main/java/com/reddio/api/v1/rest/DefaultReddioRestClient.java b/reddio-java/reddio-api/src/main/java/com/reddio/api/v1/rest/DefaultReddioRestClient.java
index 0bc7e74..f736416 100644
--- a/reddio-java/reddio-api/src/main/java/com/reddio/api/v1/rest/DefaultReddioRestClient.java
+++ b/reddio-java/reddio-api/src/main/java/com/reddio/api/v1/rest/DefaultReddioRestClient.java
@@ -7,9 +7,7 @@
import com.reddio.exception.ReddioBusinessException;
import com.reddio.exception.ReddioErrorCode;
import com.reddio.exception.ReddioException;
-import com.reddio.exception.ReddioServiceException;
import okhttp3.*;
-import okhttp3.internal.http2.ErrorCode;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
@@ -360,9 +358,13 @@ public void onFailure(Call call, IOException e) {
public void onResponse(Call call, Response response) {
try {
String responseBodyAsString = response.body() != null ? response.body().string() : "";
- ReddioErrorCode errCode = tryExtractErrorCode(responseBodyAsString);
if (!response.isSuccessful()) {
- this.future.completeExceptionally(new ReddioServiceException("reddio service not respond as sucessful", response.code(), errCode, responseBodyAsString));
+ final ResponseWrapper> model = tryExtractParseResponse(responseBodyAsString);
+ if (model != null) {
+ this.future.completeExceptionally(new ReddioBusinessException(model.getStatus(), model.getError(), ReddioErrorCode.fromCode(model.getErrorCode()), model));
+ } else {
+ this.future.completeExceptionally(new ReddioException(String.format("reddio service responded with status code %d, response body: %s", response.code(), responseBodyAsString)));
+ }
return;
}
this.future.complete(objectMapper.readValue(responseBodyAsString, typeReference));
@@ -371,15 +373,15 @@ public void onResponse(Call call, Response response) {
}
}
- public static ReddioErrorCode tryExtractErrorCode(String responseJsonString) {
+ public static ResponseWrapper