base library

Base implementation of the Result Type and tools

Classes

Err<S, F extends Object>
Error Result.
Ok<S, F extends Object>
Ok Result.
Result<S, F extends Object>
Result class representing the type union between Ok and Err.

Constants

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

Functions

executeProtected<S>(S func()) Result<S, Object>
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, Object>
Async version of executeProtected
executeProtectedAsyncResult<S>(Future<Result<S, Object>> func()) FutureResult<S, Object>
Async version of executeProtectedResult
executeProtectedResult<S>(Result<S, Object> func()) Result<S, Object>
Result unwrapping version of executeProtected. Where func returns an Result, but can still throw.

Typedefs

FutureResult<S, F extends Object> = Future<Result<S, F>>
FutureResult represents an asynchronous Result. And as such, inherits all of Results methods.
Infallible = Never
The error type for errors that can never happen
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

Panic
As with Error, Panic represents a state that should never happen and thus should never be caught.