catch idiom to propagate errors,
in the form of exceptions, up stack frames.
rescue for the the same purpose.
However, Ruby also has the
catch, which are also used
to propagate information, but not necessarily exceptions up the
Similar to Common Lisp’s exception and condition handling system, this dual, parallel mechanism
allows one to handle exceptions, that is unexpected results in the program,
rescue and use
throw for instances where
data flow across stack frames.
catch are a powerful way to handle unexpected results
in a program at higher stack levels than where the error occurs.
It allows either for centralized error or exception handling as well
as handling by code that may be better able to understand and handle the problem.
Clearly the ability to propagate data across stack frames is a useful one.