db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian d'Heureuse (JIRA)" <j...@apache.org>
Subject [jira] Created: (DERBY-2181) StandardException.printStackTrace() does not print the nested exception (cause)
Date Fri, 15 Dec 2006 17:02:23 GMT
StandardException.printStackTrace() does not print the nested exception (cause)

                 Key: DERBY-2181
                 URL: http://issues.apache.org/jira/browse/DERBY-2181
             Project: Derby
          Issue Type: Bug
    Affects Versions:
         Environment: Java 1.5
            Reporter: Christian d'Heureuse

In my Servlet application, an I/O error occurred, but I couldn't see the error message of
the I/O error.
At line 298 in StandardException.java, the I/O exception is packed into a StandardException:
   throw StandardException.newException(
When my Servlet catches the exception, it calls Throwable.printStackTrace() to generate a
detailed error message. The output of printStackTrace() does not list the nested I/O exception.

In Java 1.5, Throwable.printStackTrace() calls getCause() to get the nested exception. GetCause()
returns null, because the cause has not been set.
One solution could be to override Throwable.getCause() and initCause() in StandardException
to get and set the nested exception. There are already getNestedException() and setNestedException()
methods in StandardException which could be mapped to getCause() and initCause().

Another solution could be to change the constructor
   StandardException(String messageID, Throwable t, Object[] args)
This constructor currently calls
Instead it could call
to pass the nested Exception.
StandardException.setNestedException() could be changed to call Throwable.initCause(). But
the API docs of initCause() state stat "This method can be called at most once". So it's probably
better to override getCause() and initCause().

A problem might me that Throwable.getCause() and initCause() have been introduced in Java
1.4. But if these methods are implemented in StandardException, they would be just normal
methods in Java 1.3 and overrides in Java >= 1.4.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message