anyhow library

Enums

ErrDisplayFormat
Controls the base toString format
StackTraceDisplayFormat
How StackTrace should be displayed to the user. Known as "backtrace" in Rust anyhow.

Constants

error → const Err<dynamic, ()>
okay → const Ok<(), Object>
unit → const ()

Functions

anyhow<S>(Object err) Error
Convenience function for turning an object into an Error. Same as the original "anyhow" macro.
bail<S>(Object err) Err<S>
Convenience function for turning an object into an Err Result.
ensure(bool fn(), Object err) Result<()>
Convenience function for creating a Result to return with the err if the condition does not hold.
executeProtected<S>(S func()) Result<S>
Executes the function in a protected context. func is called inside a try catch block. If the result is not catch, then return value func returned inside an Ok. If func throws, then the thrown value is returned inside an Err.
executeProtectedAsync<S>(Future<S> func()) FutureResult<S>
Async version of executeProtected
executeProtectedAsyncResult<S>(Future<Result<S>> func()) FutureResult<S>
Async version of executeProtectedResult
executeProtectedResult<S>(Result<S> func()) Result<S>
Result unwrapping version of executeProtected. Where func returns an Result, but can still throw.

Typedefs

BaseErr<S, F extends Object> = Err<S, F>
Error Result.
BaseFutureResult<S, F extends Object> = FutureResult<S, F>
FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
BaseOk<S, F extends Object> = Ok<S, F>
Ok Result.
BaseResult<S, F extends Object> = Result<S, F>
Result class representing the type union between Ok and Err.
Err<S> = BaseErr<S, Error>
Error Result.
FutureResult<S> = Future<Result<S>>
FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
Infallible = Never
The error type for errors that can never happen
Ok<S> = BaseOk<S, Error>
Ok Result.
Result<S> = BaseResult<S, Error>
Result class representing the type union between Ok and Err.
Unit = ()
Type alias for (). Used for a Result when the returned value does not matter. Preferred over void since forces stricter types. See unit, okay, and error

Exceptions / Errors

Error
Error (Execution) wrapper around an Object error type. Usually used for chaining Objects that are Exceptions or String messages. Essentially a 'Cons' implementation for Errors.
Panic
As with Error, Panic represents a state that should never happen and thus should never be caught.