import Std.Throw
Types
Result
type Result t e =
| Ok t
| Err e
Effects
Throw
effect Throw t =
throw: fn t -> Never
Functions
catch
catch (f: a can Throw e): Result a e
catch_or
catch_or (f: a can Throw e) (default: a): a
catch_or_else
catch_or_else (f: a can Throw e) (default: fn e [_] -> a): a
on_err
on_err (f: a can Throw e) (on_err: fn e [_] -> Unit): Unit
map_err
map_err (f: t can Throw e1) (f2: fn e1 [_] -> e2): t can Throw e2
Apply the given function to the thrown value and re-throw it
unwrap_err
unwrap_err (f: t can Throw e): e can Fail
Returns the error when thrown or fails if the operation finishes without throwing.
exit_on_throw
exit_on_throw (f: a can Throw t, e) {_: Display t e2}: a can Fs, e, e2
If an error is thrown when running f, print it to stderr and exit 1