Skip to main content

BDJ exception-handler interface?

1 reply [Last post]
Joined: 2008-07-22

I'm looking for advise on how to best implment an exception handler. What I'd like to do is create an "ExceptionHandler" (or ThrowableHandler) and assign that app-wide. Basically to catch any Throwable that would otherwsie purcolate up to the default / System.err handler.

I imagine this could party be done with in each startXlet() (and optionally initXlet):

public void startXlet() throws XletStateChangeException {
try {
} catch (Throwable t) {
throw t;

But some private/inaccessible code in MHP will dispatch in new threads (rendering etc) that the above would not catch.

Is there a more general and platform-wide way to intercept any Throwables?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-05-26

If you have access to the thread group (java.lang.ThreadGroup) subclass used for the threads you wish to track, then you can override ThreadGroup.uncaughtException() method to register a sort of "global" one point handler for the entire thread group.

Please see:,%20java.lang.Throwable)

I checked that the ThreadGroup.uncaughtException() method exists on CDC/PBP platform. But, I'm not sure of the answers to the following questions:

* Does the uncaughtException() work as expected on CDC/PBP platform? On Java SE, this is the method that prints exception stack trace on System.err and so on.

* Do we not have control over which thread group class used for MHP's own threads (so that we can subclass)? I guess not.

I think the best we can do it to have try..catch(Throwable) wherever possible.