failure_kit 1.1.1 copy "failure_kit: ^1.1.1" to clipboard
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 #

  • FailureGuard doc comment referenced a non-existent package:failure_kit/dio.dart import — now points to the copy-paste example in example/dio_integration.dart.
  • Failure doc comment said "sealed class"; it is deliberately abstract so user subclasses can route to when(custom:).

Docs #

  • README: new Testing section explaining that Left/Right equality is generic-type sensitive (expect(result, Left(failure)) fails due to inferred Left<ServerFailure, dynamic>) and showing correct assertion patterns.

1.1.0 #

Features #

  • FutureEither extension on Future<Either<L, R>> — chain without intermediate awaits: mapRight, mapLeft, thenRight, thenLeft, fold, getOrElse.
  • Either.onLeft / Either.onRight — side-effect taps (e.g. logging) that return the same Either, keeping the chain intact.
  • Either.tryCatchAsync — async version of Either.tryCatch.
  • FailureGuard.callSync — synchronous counterpart of call(...) for parsing, local computation, and cache reads. Uses the same failureChain.
  • Left / Right now implement toString (Right(42), Left(error)) for readable logs and test output.

Internal #

  • Either methods 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 ServerFailure equality intentionally ignores data, cause, and stackTrace.

1.0.0 #

Initial pub.dev release.

Features #

  • Either<L, R> — sealed Left / Right with map, mapAsync, then, thenAsync, fold, getOrElse, swap, tryCatch, tryExcept, cond, condLazy.
  • Failure — abstract base class. User-defined subclasses are first-class citizens (route to when(custom:)).
  • Built-in failure types: ServerFailure (with statusCode and raw data), NoInternetFailure, TimeoutFailure, CancellationFailure, ParsingFailure, UnknownFailure.
  • FailureMapper typedef — Failure? Function(Object, StackTrace). Return null to delegate to the next mapper in the chain.
  • FailureMapperChain — interceptor-style chain. First non-null result wins. Falls back to BaseFailureMapper.
  • FailureGuard mixin — wraps async actions in Either<Failure, T> via call(...).

Notes #

  • Package is HTTP-client agnostic and has no dio dependency. See example/dio_integration.dart for a copy-paste Dio mapper.
3
likes
160
points
182
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

HTTP-client agnostic error handling for Dart/Flutter — Either pattern, typed Failures, and a pluggable mapper chain.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

meta

More

Packages that depend on failure_kit