I'm using 'Retrofit' for http transferation.
And I made a custom ErrorHandler
like below code.
public class CustomErrorHandler implements ErrorHandler {
@Override
public Throwable handleError( RetrofitError cause ) {
if ( RetrofitError.Kind.NETWORK == cause.getKind() ) {
Throwable throwable = cause.getCause();
if ( throwable instanceof SocketTimeoutException )
return throwable;
else if ( throwable instanceof ConnectException )
return throwable;
}
return cause;
}
}
When I try debugging, throwable
is instance of SocketTimeoutException
or ConnectException
in the CustomErrorHandler.handleError()
.
But, below fucntion throws UndeclaredThrowableException
.
private SignOutSuccessResponse trySignOut( String email, String userToken ) throws Exception {
RestAdapter.Builder builder = new RestAdapter.Builder();
builder.setEndpoint( ServerInfo.END_POINT_API );
builder.setErrorHandler( new CustomErrorHandler() );
if ( BuildConfig.DEBUG )
builder.setLogLevel( RestAdapter.LogLevel.FULL );
API sessionAPI = builder.build().create( API.class );
return sessionAPI.signOut( email, userToken );
}
How can I resolve this problem not this way?
I'm using
- Android studio
- Retrofit 1.7.1
- OkHttp 2.0.0
Please help me ㅠㅠ