typeover
curriculum

Curriculum Errors try and catch exercise 4 · fill-word

try and catch

Fill the missing keyword that propagates an error from a fallible call to the enclosing function's return. Three letters, lowercase — the same keyword used many times in Module 1.

TypeScript reference
Fill the blanks →

About this theme

There are three ways to consume an error union. try expr is the propagator: on error, return the error to the caller; on success, unwrap the value. expr catch <default> substitutes a fallback value (analogous to optionals orelse). expr catch |err| { ... } captures the error and runs a handler block — pair with a switch on err to handle each case. Once these three are reflex, error handling reads cleanly without exception-handler ceremony.