kib_utils library
A utility library providing various utils.
Included is the Result class, a generic class representing the result of an operation that can either succeed or fail.
Classes
-
Failure<
S, E extends Exception> -
Represents a failed outcome of an operation, containing an error of type
E
. -
Result<
S, E extends Exception> - A generic class representing the result of an operation that can either succeed or fail.
-
Success<
S, E extends Exception> -
Represents a successful outcome of an operation, containing a value of type
S
.
Extensions
-
FutureResultExtension
on Future<
Result< S, E> > - Extension methods for handling asynchronous operations that return a Result.
Functions
-
failure<
S, E extends Exception> (E error) → Result< S, E> -
Creates a Failure instance containing the provided
error
. -
success<
S, E extends Exception> (S value) → Result< S, E> -
Creates a Success instance containing the provided
value
. -
tryResult<
S, E extends Exception> (S fn(), E onError(dynamic error)) → Result< S, E> -
Executes a synchronous function
fn
and wraps its result in a Result. -
tryResultAsync<
S, E extends Exception> (Future< S> fn(), E onError(dynamic error)) → Future<Result< S, E> > -
Executes an asynchronous function
fn
and wraps its result in a Result. -
tryResultAsyncE<
S, E extends Exception> (Future< S> fn(), Exception onError(Exception error)) → Future<Result< S, Exception> > -
Executes an asynchronous function
fn
and wraps its result in a Result, specifically handling Exception types. -
tryResultE<
S, E extends Exception> (S fn(), Exception onError(Exception error)) → Result< S, Exception> -
Executes a synchronous function
fn
and wraps its result in a Result, specifically handling Exception types.