mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-22 05:38:55 +00:00
improve error reporting
This commit is contained in:
parent
8949f6a625
commit
2a193a60ad
2 changed files with 23 additions and 5 deletions
|
|
@ -132,6 +132,9 @@ public abstract class HabiticaBaseApplication extends MultiDexApplication {
|
|||
}
|
||||
}
|
||||
Fresco.initialize(this);
|
||||
|
||||
RxErrorHandler.init(crashlyticsProxy);
|
||||
|
||||
checkIfNewVersion();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,21 +2,36 @@ package com.habitrpg.android.habitica.helpers;
|
|||
|
||||
import android.util.Log;
|
||||
|
||||
import rx.android.BuildConfig;
|
||||
import com.habitrpg.android.habitica.BuildConfig;
|
||||
import com.habitrpg.android.habitica.proxy.CrashlyticsProxy;
|
||||
|
||||
import rx.functions.Action1;
|
||||
|
||||
public class RxErrorHandler {
|
||||
|
||||
static private RxErrorHandler instance;
|
||||
private CrashlyticsProxy crashlyticsProxy;
|
||||
|
||||
public static void init(CrashlyticsProxy crashlyticsProxy) {
|
||||
instance = new RxErrorHandler();
|
||||
instance.crashlyticsProxy = crashlyticsProxy;
|
||||
}
|
||||
|
||||
public static Action1<Throwable> handleEmptyError() {
|
||||
//Can't be turned into a lambda, because it then doesn't work for some reason.
|
||||
return new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("ObservableError", Log.getStackTraceString(throwable));
|
||||
}
|
||||
RxErrorHandler.reportError(throwable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void reportError(Throwable throwable) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
Log.e("ObservableError", Log.getStackTraceString(throwable));
|
||||
} else {
|
||||
instance.crashlyticsProxy.logException(throwable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue