retrofit
Interface ErrorHandler


public interface ErrorHandler

A hook allowing clients to customize error exceptions for synchronous requests.

Author:
Sam Beran [email protected]

Field Summary
static ErrorHandler DEFAULT
          An ErrorHandler which returns the original error.
 
Method Summary
 Throwable handleError(RetrofitError cause)
          Return a custom exception to be thrown for a RetrofitError.
 

Field Detail

DEFAULT

static final ErrorHandler DEFAULT
An ErrorHandler which returns the original error.

Method Detail

handleError

Throwable handleError(RetrofitError cause)
Return a custom exception to be thrown for a 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;
   }
 }
 

Parameters:
cause - the original RetrofitError exception
Returns:
Throwable an exception which will be thrown from the client interface method. Must not be null.


Copyright © 2013 Square, Inc.. All Rights Reserved.