A catch clause is a clause of a try expression that pattern-matches and handles an error, exit, or throw.
A catch clause handles a runtime error, exit, or throw from a try expression. Execution moves from the do block to a matching catch branch, whose patterns receive the event type and value. section 8.1.2
Match the runtime event deliberately:
Match :error for raised errors, :throw for thrown values, or :exit for exits. section 8.1.2
Treat the try expression's value as the last expression in either the do block or the selected catch branch. section 8.1.2
How Elixir in Action, Third Edition covers it
How deep it goes
Explains syntax, event types, pattern matching, return values, and cleanup, but stops short of broader fault-tolerance architecture.
Examples
Uses a helper lambda, raised errors, thrown values, exits, tuple-pattern catches, and cleanup output.
What it assumes
Assumes familiarity with Elixir expressions and runtime events while teaching catch patterns from the try mechanism.
What you can do after
Apply it via Elixir try expressions to classify, selectively handle, and return values from runtime events.
How it connects
Connects try expressions with pattern matching, raise, throw, exit, and after clauses.
100 SQL Server Mistakes and How to Avoid ThemTRY..CATCH is T-SQL control-flow syntax that executes protected code in a TRY block and transfers control to a CATCH block when a catchable error occurs.
try-catch statementpart of · A try-catch statement is a control-flow construct that executes code under exception handling and transfers control to a matching handler when an exception is raised.
exceptionused by · An exception is a runtime signal or object representing an abnormal condition that interrupts ordinary program flow and may be handled or propagated.
error handlingimplements · Error handling is the practice of detecting, representing, propagating, reporting, and responding to errors or failures during software operation.
finallyincludes · A finally clause is an exception-handling block that runs when control leaves an associated protected block, whether normally or exceptionally.
return statementhas part · A return statement ends the current function or routine invocation and optionally supplies its result to the caller.
global error handlercontrasts with · A global error handler is a runtime-level mechanism that receives or reports errors escaping local error-handling mechanisms.
This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.