[TIMOB-8890] Android: Unable to catch any errors while creating a crash reporter
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2013-02-16T00:38:33.000+0000 |
Affected Version/s | Release 2.0.1 |
Fix Version/s | Release 3.0.0 |
Components | Android |
Labels | core |
Reporter | Nikhil Sharma |
Assignee | Allen Yeung |
Created | 2012-04-25T15:11:09.000+0000 |
Updated | 2017-03-13T18:24:04.000+0000 |
Description
The customer wants to create a crash reporter. He needs to have a global listener that just catches errors and makes an api call before it raises. At the moment he's just trying to log beforehand then raise. The below code doesn't catch any errors. Is it because it's a KrollRuntime Thread not a Thread?
@Kroll.method
public void start() {
CrashHandler.register(TiApplication.getAppRootOrCurrentActivity().getApplicationContext());
}
public class CrashHandler {
private static final String LCAT = "CrashModule";
private static final boolean DBG = TiConfig.LOGD;
private static class AppceleratorCrashExceptionHandler implements UncaughtExceptionHandler {
private UncaughtExceptionHandler defaultExceptionHandler;
public AppceleratorCrashExceptionHandler(UncaughtExceptionHandler defaultExceptionHandlerIn) {
defaultExceptionHandler = defaultExceptionHandlerIn;
}
public void uncaughtException(Thread t, Throwable e) {
Log.d(LCAT, "==============I'm DOING IT!");
defaultExceptionHandler.uncaughtException(t, e);
}
}
public static void register(Context context) {
UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(new AppceleratorCrashExceptionHandler(currentHandler));
}
}
Is it possible to accomplish this with titanium?
Closing ticket as duplicate.