Exceptional Ruby
summary
Explains Ruby’s actual raise lifecycle: Ruby calls an object’s exception.exception coercion, then calls set_backtrace, sets the global $! error variable, and unwinds the stack; shows how to override raise and demos the Hammer Time Jam interactive error console. Demonstrates retry, nested exceptions (carry original via an attribute), using at_exit for crash logging, advocating circuit-breakers and contingency methods, and recommends structuring libraries around three classes — user error, logic error, transient error — so callers can choose handling semantics.
AI-written summary · about
chapters (50)
- 0:00Intro
- 2:11Lifecycle of an Exception
- 2:23Raising Exceptions
- 3:15raise with a string
- 3:48raise is a method on Kernel
- 4:02Overriding raise
- 4:42raise internals
- 5:04Get the exception object
- 5:35exception()
- 5:52Implement your own #exception
- 6:32Set the backtrace
- 6:42Set global error variable
- 7:35Unwind the call stack
- 7:49rescue with no arguments
- 8:18rescue with just a name
- 8:40rescue with a class
- 9:18rescue with a dynamic matcher
- 10:23ensure with explicit return
- 10:43retry
- 11:46raise during exception handling
- 13:48Re-raise with new message
- 14:14Failures without context
- 14:48Adding context
- 16:03Re-raise with message, backtrace
- 16:15Re-raise with no arguments
- 17:30Uncaught exceptions
- 18:04A simple crash logger
- 18:58Responding to Failures
- 19:15Return an error value
- 19:27Return a benign value
- 19:59Remote Failure Reporting
- 22:20Avoid the failure cascade
- 22:40Your Failure Handling Strategy
- 23:04Question #1
- 25:24Question #2
- 26:06What constitutes an exception?
- 26:57Caller-defined fallback strategy
- 28:02Question #4
- 29:41Isolate exception handling code
- 29:53begin is a code smell
- 30:39Method-level exception clauses
- 31:33Contingency methods
- 33:01Exception Safety
- 33:27The Three Guarantees
- 35:50Tag your library exceptions
- 39:27User Error
- 39:53Logic Error
- 40:04Transient Error
- 40:33Three essential exception classes
- 40:55A Recap
related talks
44mExceptional Ruby
25mThings You Didn't Know About Exceptions
37mException Handling Designing Robust Software
39mSteal This Talk: The Best Features Ruby Doesn't Have (Yet)
30mRuby on Fails: effective error handling with...
38mSpelunking in Ruby
27mYes, &…: Ruby’s Secret Talent for Improvisation
15mRUBY MAGIC
