Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Full information for Ruby errors (See related posts)

Sometimes I want to be able to print out everything about an error: it's class, message and the stack trace. So how about this:

Update: followed suggestion by onarap and changed the line breaks to $/. No syntax highlighting because the code breaks the snippet parser.


class StandardError
def info
"#{self.class}: #{message}#$/#{backtrace.join($/)}"
end
end

Comments on this post

onarap posts on Aug 17, 2006 at 08:34
Nice. Maybe it's better to use $/ as '\n' would not work well on windows.

You need to create an account or log in to post comments to this site.


Click here to browse all 5829 code snippets

Related Posts