Last active
March 1, 2017 05:44
-
-
Save parthdave93/559f2f99ff4b2bceed4213e4e926da5f to your computer and use it in GitHub Desktop.
Retrofit will throw error for 401,402 type server response if we want to catch that in RxJava, Things to do for Retrofit RxJava Error Handling -> Check OperatorMapResponseToBodyOrError.java for error handling other classes are just to instanciate the Rxjava adapter on proejct level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (throwable instanceof HttpException) { | |
Response response = ((HttpException) throwable).response(); | |
RetrofitError commonResponse = null; | |
if (response != null) { | |
Gson gson = new Gson(); | |
try { | |
commonResponse = gson.fromJson(response.errorBody().string(), RetrofitError.class); | |
CommonUtilities.showAlertDialog(context, commonResponse.getMessage()); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
webApiResponseInterface.onError(commonResponse); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment