Hello,
I was looking at implementing an UncaughtExceptionHandler, possible with all other versions of java with the code below, however after looking at RIM's stripped down version of the Thread class, the api doesn't appear to exist.
I was wondering if anyone has done it, or is aware of the fact whether it's possible or not.
The code would be analogous to what's below:
Code:
private void setUncaughtExceptionHandler() {
MyExceptionHandler meh = new MyExceptionHandler(Thread.currentThread().getUncaughtExceptionHandler());
Thread.currentThread().setUncaughtExceptionHandler(meh);
}
private class MyExceptionHandler implements Thread.UncaughtExceptionHandler {
private UncaughtExceptionHandler defaultHandler;
public MyExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
defaultHandler = uncaughtExceptionHandler;
}
public void uncaughtException(Thread thread, Throwable ex) {
//log exception info here
defaultHandler.uncaughtException(thread, ex);
}
public void unset() {
Thread.currentThread().setUncaughtExceptionHandler(defaultHandler);
}
} Thank you!