Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Fix Retrofit call cancellation triggering error
Browse files Browse the repository at this point in the history
OkHttp throws a standard IOException with the message "Canceled"
whenever any call is cancelled, which is passed on by the base
ErrorHandlingCallback implementation to the ErrorUtils.getErrorMessage()
method, which in turn interprets it as a network connectivity issue, and
returns the appropriate error message. This commit fixes the issue by
adding a check in the ErrorHandlingCallback implementation’s failure
callback to verify that the call hasn’t been cancelled, before
delivering the error message.
  • Loading branch information
1zaman authored and christopher lee committed Nov 11, 2016
1 parent a1cb02d commit 4747574
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void onFailure(@NonNull Call<T> call, @NonNull Throwable error) {
if (progressCallback != null) {
progressCallback.finishProcess();
}
if (messageCallback != null) {
if (messageCallback != null && !call.isCanceled()) {
messageCallback.onMessage(callTrigger.getMessageType(),
ErrorUtils.getErrorMessage(error, context));
}
Expand Down

0 comments on commit 4747574

Please sign in to comment.