result_monad library
A Dart implementation of the Result Monad which models success (ok) or failure (error) operation return types to allow for more expressive return generation/processing without using exceptions
Classes
-
Result<
T, E> - The Result Monad type which will encapsulate a success (ok) value of type T or a failure (error) value of type E
Extensions
-
FutureResultExtension
on Future<
Result< T, E> > - Extension methods on Future
Functions
-
runCatching<
T> (Result< T, dynamic> function()) → Result<T, dynamic> - Allows library users to wrap potential exception throwing code in a way that transforms thrown exception objects into a failure monad. Runs the passed in function catching any thrown error objects and returning it as a result monad.
-
runCatchingAsync<
T> (FutureResult< T, dynamic> function()) → FutureResult<T, dynamic> - Runs the passed in async function catching any thrown error objects and returning it as a result monad.
Typedefs
-
FutureResult<
T, E> = Future< Result< T, E> > -
A shorthand type notation for Result futures
FutureResult<int,String> func() async {}
Exceptions / Errors
- ResultMonadException
- Exception type for Result Monad specific exceptions (such as getting the success value when the Result contained is a failure.