failure_kit 1.0.0
failure_kit: ^1.0.0 copied to clipboard
HTTP-client agnostic error handling for Dart/Flutter — Either pattern, typed Failures, and a pluggable mapper chain.
Changelog #
1.0.0 #
Initial pub.dev release.
Features #
Either<L, R>— sealedLeft/Rightwithmap,mapAsync,then,thenAsync,fold,getOrElse,swap,tryCatch,tryExcept,cond,condLazy.Failure— abstract base class. User-defined subclasses are first-class citizens (route towhen(custom:)).- Built-in failure types:
ServerFailure(withstatusCodeand rawdata),NoInternetFailure,TimeoutFailure,CancellationFailure,ParsingFailure,UnknownFailure. FailureMappertypedef —Failure? Function(Object, StackTrace). Returnnullto delegate to the next mapper in the chain.FailureMapperChain— interceptor-style chain. First non-null result wins. Falls back toBaseFailureMapper.FailureGuardmixin — wraps async actions inEither<Failure, T>viacall(...).
Notes #
- Package is HTTP-client agnostic and has no
diodependency. Seeexample/dio_integration.dartfor a copy-paste Dio mapper.