throw/catch vs. raise/rescue
Just a piece of Ruby trivia: Ruby has both throw
/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.