Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8890] Android: Unable to catch any errors while creating a crash reporter

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionDuplicate
Resolution Date2013-02-16T00:38:33.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sRelease 3.0.0
ComponentsAndroid
Labelscore
ReporterNikhil Sharma
AssigneeAllen Yeung
Created2012-04-25T15:11:09.000+0000
Updated2017-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?

Comments

  1. Allen Yeung 2013-02-16

  2. Lee Morris 2017-03-13

    Closing ticket as duplicate.

JSON Source