One of the APIs that is available on J2SE but not J2ME is the
RuntimeException constructor with the following signature:
RuntimeException(String, Throwable)
We use this a lot today in order to make the stack trace as detailed as
possible. Without the original exception, it would be much harder to trace
where a re-thrown exception was coming from; it's okay when it's a known
error (and thus has a unique message ID that we can search for), but if
it's not (NPE, etc.), you're in trouble.
Part of Barry's J2ME port involves changing usage of
RuntimeException(String, Throwable) to RuntimeException(String). I'd like
to avoid losing the extra stack trace data if at all possible, but it will
be tricky. My initial idea is to hack around it using a new class that
extends RuntimeException but assumes the J2ME-style API. Since
RuntimeException is not part of any API, replacing its usage with this new
class would be a simple search and replace.
What do you think? The necessary code is below:
public class DetailedRuntimeException extends RuntimeException
{
public Throwable _cause = null;
public DetailedRuntimeException(String message)
{
super(message);
}
public DetailedRuntimeException(String message, Throwable cause)
{
super(message);
_cause = cause;
}
public Throwable getCause()
{
return _cause;
}
public printStackTrace(PrintWriter writer)
{
super.printStackTrace(writer);
if (_cause != null)
_cause.printStackTrace(writer);
}
}
Dan Jemiolo
IBM Corporation
Research Triangle Park, NC
+++ I'm an engineer. I make slides that people can't read. Sometimes I eat
donuts. +++
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]