failure_kit library

Classes

BaseFailureMapper
Built-in base mapper — handles standard Dart exceptions.
CancellationFailure
Failure representing cancelled requests.
Either<L, R>
Represents a value of one of two possible types. Instances of Either are either an instance of Left or Right.
Failure
Base class for all application failures.
FailureMapperChain
An ordered chain of FailureMappers.
Left<L, R>
Used for "failure"
NoInternetFailure
Failure representing network connectivity issues.
ParsingFailure
Failure representing data parsing/serialization errors.
Used for "success"
ServerFailure
Failure representing server/API errors with HTTP status codes.
TimeoutFailure
Failure representing request timeout.
UnknownFailure
Failure for unexpected/unknown errors.

Mixins

FailureGuard
Mixin that wraps async calls in Either, converting exceptions to Failure.

Extensions

FutureEither on Future<Either<L, R>>
Chaining helpers for Future<Either> — lets you compose without the (await x).map(...) dance:

Typedefs

FailureMapper = Failure? Function(Object error, StackTrace stackTrace)
Maps an error to a Failure, or returns null if this mapper does not handle the given error (passes it to the next in the chain).
Lazy<T> = T Function()