failure_kit 1.1.1
failure_kit: ^1.1.1 copied to clipboard
HTTP-client agnostic error handling for Dart/Flutter — Either pattern, typed Failures, and a pluggable mapper chain.
Changelog #
1.1.1 #
Fixed #
FailureGuarddoc comment referenced a non-existentpackage:failure_kit/dio.dartimport — now points to the copy-paste example inexample/dio_integration.dart.Failuredoc comment said "sealed class"; it is deliberatelyabstractso user subclasses can route towhen(custom:).
Docs #
- README: new Testing section explaining that
Left/Rightequality is generic-type sensitive (expect(result, Left(failure))fails due to inferredLeft<ServerFailure, dynamic>) and showing correct assertion patterns.
1.1.0 #
Features #
FutureEitherextension onFuture<Either<L, R>>— chain without intermediateawaits:mapRight,mapLeft,thenRight,thenLeft,fold,getOrElse.Either.onLeft/Either.onRight— side-effect taps (e.g. logging) that return the sameEither, keeping the chain intact.Either.tryCatchAsync— async version ofEither.tryCatch.FailureGuard.callSync— synchronous counterpart ofcall(...)for parsing, local computation, and cache reads. Uses the samefailureChain.Left/Rightnow implementtoString(Right(42),Left(error)) for readable logs and test output.
Internal #
Eithermethods are now implemented once in the sealed base class via Dart 3 switch expressions instead of per-subclass overrides. No public API changes.- Documented that
ServerFailureequality intentionally ignoresdata,cause, andstackTrace.
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.