Skip to content
FutureBlitz

    Install

    Learn

    Errors

    Throw and catch errors, define your own, clean up with Finally and Defer, and read panics.

    FutureBlitz separates two kinds of failure. An error is something a correct program should expect and handle: a missing file, a number that doesn’t parse, a server that doesn’t answer. A function that can fail says which errors it throws, and the compiler makes every caller deal with them, so none is ignored by accident. A panic is a bug, like an index out of range or a failed Assert: it stops the program at once, with a message and a stack trace that point at the line. This area covers both, and the tools that clean up whichever way a block ends.

    Tutorials

    1. Throw and Catch Declare what a function throws, throw an error, and handle it with Try, Catch, and Try?.
    2. Error types Define error Classes with details of their own, catch each kind apart, and wrap one error in another.
    3. Finally and Defer Run cleanup whether a block succeeds or fails, with a Try's Finally or with Defer.
    4. Panics and stack traces Stop the program on a bug with Assert and Panic, and read the stack trace that points at it.

    The rules behind this area are in the language reference.

    Report an issue with this page or with FutureBlitz on GitHub.