mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
better error reporting for network calls
This commit is contained in:
parent
5c4951c859
commit
495cb04ed5
1 changed files with 10 additions and 2 deletions
|
|
@ -23,10 +23,15 @@ import android.support.v7.app.AlertDialog;
|
|||
import java.io.IOException;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.net.ssl.SSLPeerUnverifiedException;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
|
|
@ -159,9 +164,12 @@ public class APIHelper implements Action1<Throwable> {
|
|||
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
if (throwable.getClass().equals(ConnectException.class)) {
|
||||
final Class<?> throwableClass = throwable.getClass();
|
||||
if (throwableClass.equals(ConnectException.class) || throwableClass.isAssignableFrom(SSLException.class)) {
|
||||
this.showConnectionProblemDialog(R.string.internal_error_api);
|
||||
} else if (throwable.getClass().equals(HttpException.class)) {
|
||||
} else if (throwableClass.equals(SocketTimeoutException.class) || throwableClass.equals(UnknownHostException.class)) {
|
||||
this.showConnectionProblemDialog(R.string.network_error_no_network_body);
|
||||
} else if (throwableClass.equals(HttpException.class)) {
|
||||
HttpException error = (HttpException)throwable;
|
||||
retrofit2.Response<?> response = error.response();
|
||||
ErrorResponse res = null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue