RbRuby · Lesson 9 of 11
Error Handling
Ruby calls exceptions exceptions. `begin/rescue/ensure` is Ruby's try/catch/finally. `raise` throws them. Custom exception classes are just subclasses of StandardError.
◆ Note
Rescue without a class catches StandardError and its descendants — which covers almost all application errors. Never rescue Exception (the base class) — it catches things like SignalException (Ctrl+C) and SystemExit, which should be allowed to propagate.
Rescue without a class catches StandardError and its descendants — which covers almost all application errors. Never rescue Exception (the base class) — it catches things like SignalException (Ctrl+C) and SystemExit, which should be allowed to propagate.