wood burning stoves 2.0*
The moose likes Java in General and the fly likes Pretty print exceptions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pretty print exceptions" Watch "Pretty print exceptions" New topic
Author

Pretty print exceptions

Rune Skjelvik
Greenhorn

Joined: Nov 30, 2001
Posts: 2
A common solution when encountering exceptions is the "ugly" printstacktrace() in order to get enough information printed to fully understand the reason the exception occured.

Such stacktraces seldom do well in logs, and by java 1.4 there is a new method on Throwable which seems to make it easier to extract information from the exception/stacktrace...

However applications can be run on VM prior to 1.4, so this solution is not suitable...

My question ::
Does anyone know of some open source project or equivalent which deals with the problem of extracting information from exceptions, making it possible to make more reasonable logstatements than the damn printStackTrace()??
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Dear Rune,
Have you thought about dealing with de getStackTrace() method of Throwable?. The zeroth element of the StackTraceElement[] returned provides information about the last method invoked.
I think this in addition to the toString() method gives a reasonable information.

[ November 30, 2004: Message edited by: Ignacio del Valle ]

[ November 30, 2004: Message edited by: Ignacio del Valle ]
[ December 02, 2004: Message edited by: Ignacio del Valle ]

SCJP, OCMJD, OCMJEA
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pretty print exceptions
 
Similar Threads
Exceptions, implementing
Use of exception handling
Exceptions
Chaining Exceptions.
Hibernate does not return any result