ela
Contents

ManualPackages

Error values

In the terminalela --spec error-values

error.is asks what try gave. The Error itself, its fields, its kinds and fail are in LANGUAGE.md, Errors as values.

Built-inDoes
error.is(x)Whether x is an Error: false for null, and for any other value
error.is(x, Error.NOT_FOUND)Whether x is an Error with that kind, its own or any cause's down its chain
error.is(x, 2)Whether x is an Error with that exit code, its own or any cause's: a command's exit status, or the number fail named
  • The second value is told apart by its type, as fail's is: a kind or a whole number; any other is an error naming the two forms. x may be anything, null included, so error.is never needs a test of its own first.
err = try grep -q TODO notes.mdif error.is($err, 2)    warn "notes.md can't be read: $err"end if data, err = try load_site()if error.is($err, Error.NOT_FOUND)    echo "no config yet; writing the default"    file.write("config.toml", $DEFAULT_CONFIG)end if