mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
fixed a major crash on time out in login screen.
This commit is contained in:
parent
51ed7b9a2f
commit
490cc56dcd
@ -148,11 +148,13 @@ public class RestProvider {
|
||||
}
|
||||
|
||||
@Nullable public static GitHubErrorResponse getErrorResponse(@NonNull Throwable throwable) {
|
||||
RetrofitException error = (RetrofitException) throwable;
|
||||
try {
|
||||
return error.getErrorBodyAs(GitHubErrorResponse.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (throwable instanceof RetrofitException) {
|
||||
RetrofitException error = (RetrofitException) throwable;
|
||||
try {
|
||||
return error.getErrorBodyAs(GitHubErrorResponse.class);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.fastaccess.provider.rest.handler;
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.CallAdapter;
|
||||
@ -53,6 +54,9 @@ public class RxErrorHandlingCallAdapterFactory extends CallAdapter.Factory {
|
||||
}
|
||||
|
||||
private RetrofitException asRetrofitException(Throwable throwable) {
|
||||
if (throwable instanceof SocketTimeoutException) {
|
||||
return RetrofitException.unexpectedError(throwable);
|
||||
}
|
||||
if (throwable instanceof HttpException) {
|
||||
HttpException httpException = (HttpException) throwable;
|
||||
Response response = httpException.response();
|
||||
|
||||
@ -39,7 +39,7 @@ class LoginPresenter extends BasePresenter<LoginMvp.View> implements LoginMvp.Pr
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onError(throwable);
|
||||
sendToView(view -> view.showErrorMessage(throwable.getMessage()));
|
||||
}
|
||||
|
||||
@Override public void onTokenResponse(@Nullable AccessTokenModel modelResponse) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user