public interface ErrorHandler
response
exceptions.Modifier and Type | Field and Description |
---|---|
static ErrorHandler |
DEFAULT
An
ErrorHandler which returns the original error. |
Modifier and Type | Method and Description |
---|---|
Throwable |
handleError(RetrofitError cause)
Return a custom exception to be thrown for a
RetrofitError . |
static final ErrorHandler DEFAULT
ErrorHandler
which returns the original error.Throwable handleError(RetrofitError cause)
RetrofitError
. It is recommended that you
pass the supplied error as the cause to any new exceptions.
If the return exception is checked it must be declared to be thrown on the interface method.
Example usage:
class MyErrorHandler implements ErrorHandler { @Override public Throwable handleError(RetrofitError cause) { Response r = cause.getResponse(); if (r != null && r.getStatus() == 401) { return new UnauthorizedException(cause); } return cause; } }
cause
- the original RetrofitError
exceptionnull
.Copyright © 2015 Square, Inc.. All Rights Reserved.