throw/catch vs. raise/rescue

Mar 22, 2011
• Ben

Just a piece of Ruby trivia: Ruby has boththrow/catch as well as raise/rescue. Most newbie Rubyists don’t know this. There’s a section of the Pickaxe book that discusses them both.

Essentially, rescue is used for exceptions and error control while catch is used for symbols and flow control. The idea is that you shouldn’t use exceptions to change the flow of your program, but rather to handle errors.