Error handling with Monads in Ruby
summary
A Ruby example app that updates one user demonstrates using dry-monads (the dry-rb Result type) and Result/Try composition to replace exceptions: validate fields, validate email, find (ActiveRecord), update, deliver mail — each returns Success or Failure and composes with bind; Try wraps exception-raising calls. Code uses yield sugar and guard clauses to flatten flow, returns JSON on success, and short-circuits on first Failure. It works but requires a mindset shift and extra onboarding.
AI-written summary · about
chapters (10)
- 0:00Intro
- 1:24History of errors
- 3:32Arrow values
- 4:51Exceptions
- 6:40Context loss corrupt state
- 7:59Shifting semantics in notion
- 8:37Concurrent and parallel programming
- 9:42Simple exceptions
- 10:52Monads
- 13:15Code examples








