Works for me. You could also (if you want) create two versions. Use the
one below for ME, and have a simple one for SE that looks like:
public class DetailedRuntimeException extends RuntimeException
{
public DetailedRuntimeException(String message)
{
super(message);
}
public DetailedRuntimeException(String message, Throwable cause)
{
super(message, cause);
}
//etc...
}
Then package the ME one with the rest of the Harmony stuff, and put the
SE version in whatever bundle we designate to hold the SE-specific stuff
(like a WSDLUtils with regex enabled or whatever).
Cheers,
Joel
-----Original Message-----
From: Daniel Jemiolo [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 11, 2007 2:56 PM
To: [email protected]
Subject: RuntimeException constructor for J2ME
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]
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose it
to anyone else. If you received it in error please notify us immediately and
then destroy it.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]