Errors
throw, try, catch, finally — raising an error, catching it, and moving on.
Section 5.2 promised it: “throw ends a method as well as return does — that keyword will
come in its own time.” And 6.1 had you meet a run-time error defenceless: the program fell,
full stop.
Its time has come. This section teaches how to throw an error, catch it, and keep the program going — your own errors first, then the language’s.
In this section
- 8.1Throwing and catching
throw raises an instance of an archetype; catch takes it by its exact type.
- 8.2The language's errors, and finally
Catching what the language throws — and guaranteeing a cleanup, whatever happens.