result_kt library

Classes

Result<T>
A discriminated union that encapsulates a successful outcome with a value of type T or a failure with an arbitrary error and stack trace.

Extensions

StreamExtension on Stream<T>
Functions for using Stream with the Result.

Functions

runCatching<R>(Block<R> block, {bool test(Object error)?}) Result<R>
Calls the specified function block and returns your value encapsulated in the Result if invocation is successful, catches any error that is thrown from the block function execution, then test is called with the error value, if test is true, the error and the StackTrace are encapsulating it as a failure in Result, otherwise, if test is false, then the error is rethrow.

Typedefs

Block<R> = R Function()
runCatching function