I'm not exactly sure what you mean. If you only want to change how
errors are displayed, why not simply wrap the whole script in a
Single begin-end blocks are only necessary if you actually want to do
something specific with the error. It doesn't make sense to write the
same error handler for every code that may faild.
However, there are ways to shorten error code. For single statements,
you can use the rescue modifier:
"" + 1 rescue puts 'Rescued!'
This catches any StandardError raised by the statement before the
You may also write a method that takes a block and catches errors from
"" + 1
Posted via http://www.ruby-forum.com/.