This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

user-friendly way of printing the output of printStackTrace

 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i was wondering if there's a user-friendly way of printing the output of the prinStackTrace() method.

Thanks
Preetham
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic