Reraising Exceptions in Ruby

February 14th, 2008

Don’t do this:
1
2
3
    rescue Exception => e
      # other stuff
      raise "#{e.class}: #{e.message}"
Do this:
1
2
3
    rescue Exception => e
      # other stuff
      raise

raise without any arguments will reraise the current exception, complete with class, message, and stack trace.

See also Programming Ruby on exceptions.

Sorry, comments are closed for this article.