wood burning stoves 2.0*
The moose likes Java in General and the fly likes user-friendly way of printing the output of printStackTrace Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "user-friendly way of printing the output of printStackTrace" Watch "user-friendly way of printing the output of printStackTrace" New topic
Author

user-friendly way of printing the output of printStackTrace

Preetham Chandrasekhar
Ranch Hand

Joined: Nov 05, 2003
Posts: 98
Hi,
i was wondering if there's a user-friendly way of printing the output of the prinStackTrace() method.

Thanks
Preetham


"In theory, there is no difference between theory and practice. But, in practice, there is."<br /> - Jan L.A. van de Snepscheut
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
Hi,

I guess we would have to define what really we would mean by "user friendly way" and then it would be just matter of getting the stacktrace via Exception#getStackTrace() and formatting each StackTraceElement in way want..

Regards
Maulin
Dave Brookes
Greenhorn

Joined: Feb 23, 2000
Posts: 17
Couple of ideas that I have used (but it does depend on that definitiion of "user friendly")..
1. If you want a more meaningful exception then you could create your own Exception subclass and then query its state instead. That way you could create more meaningful traces for your context but at the cost of the exception object overhead.

2 A variant of the printStackTrace method takes a printstream parameter so you could capture output to a file etc.


Regards,<br />Dave
 
jQuery in Action, 2nd edition
 
subject: user-friendly way of printing the output of printStackTrace