diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/ApiCallback.java b/graphenej/src/main/java/cy/agorise/graphenej/api/ApiCallback.java index dc04acf..188711a 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/ApiCallback.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/ApiCallback.java @@ -1,5 +1,7 @@ package cy.agorise.graphenej.api; +import javax.annotation.Nullable; + import cy.agorise.graphenej.models.JsonRpcResponse; import okhttp3.Response; @@ -19,8 +21,8 @@ public interface ApiCallback { /** * Method called whenever there was an error and the response could not be delivered. * - * @param t Error Trowable, potentially with some details about the problem. + * @param t Error Throwable, potentially with some details about the problem. * @param response Node response, if any */ - void onFailure(Throwable t, Response response); + void onFailure(Throwable t, @Nullable Response response); } diff --git a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java index 19172c9..6fcc810 100644 --- a/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java +++ b/graphenej/src/main/java/cy/agorise/graphenej/api/android/NetworkService.java @@ -565,7 +565,10 @@ public class NetworkService { // Executing callback, if present with the parsed response if(mCallbackMap.containsKey(response.id)){ ApiCallback callback = mCallbackMap.get(response.id); - callback.onResponse(parsedResponse, text); + if(response.error == null) + callback.onResponse(parsedResponse, text); + else + callback.onFailure(new Exception("Exception while trying to parse node response. Message: " + response.error.message), null); mCallbackMap.remove(response.id); }