android - Rethrow UncaughtExceptionHandler Exception after Logging It -



android - Rethrow UncaughtExceptionHandler Exception after Logging It -

in application class trying grab forcefulness close before happens, can log , rethrow android can handle it. since users not study forcefulness closes.

i developing in eclipse, , eclipse not allowing me rethrow exception. shows error saying "unhandled exception type throwable: surround try/catch". how can rethrow exception?

public class mainapplication extends application { @override public void oncreate() { super.oncreate(); seek { //log exception before app forcefulness closes thread.currentthread().setuncaughtexceptionhandler(new uncaughtexceptionhandler() { @override public void uncaughtexception(thread thread, throwable ex) { analyticsutils.getinstance(mainapplication.this).trackevent( "errors", // category "mainactivity", // action "force close: "+ex.tostring(), // label 0); // value analyticsutils.getinstance(mainapplication.this).dispatch(); toast.maketext(mainapplication.this, "snap! broke. please study forcefulness close can prepare it.", toast.length_long); //rethrow exception user can study //throw ex; //<-- **eclipse showing error surround try/catch** } }); } grab (exception e) { e.printstacktrace(); } }

}

apologies, not android expert - looks can't throw ex because method signature "void uncaughtexception(thread, throwable)" doesn't declare "throws" anything.

assuming you're overriding api interface , (a) can't modify signature , (b) don't want because you'd throwing out of context, instead utilize decorator pattern , subclass default uncaughtexceptionhandler implementation log message , allow carry on processing usual?

edit: untested, might bit like:

final uncaughtexceptionhandler subclass = thread.currentthread().getuncaughtexceptionhandler(); thread.currentthread().setuncaughtexceptionhandler(new uncaughtexceptionhandler() { @override public void uncaughtexception(thread thread, throwable ex) { // code analyticsutils.getinstance(mainapplication.this).trackevent( "errors", // category "mainactivity", // action "force close: "+ex.tostring(), // label 0); // value analyticsutils.getinstance(mainapplication.this).dispatch(); toast.maketext(mainapplication.this, "snap! broke. please study forcefulness close can prepare it.", toast.length_long); // carry on prior flow subclass.uncaughtexception(thread, ex); } });

android eclipse exception exception-handling

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -