> flutter-error-handling

Functional error handling using Dartz and Either. Use when implementing functional error handling, Either monad, or failure types in Flutter. (triggers: lib/domain/**, lib/infrastructure/**, Either, fold, Left, Right, Failure, dartz)

fetch
$curl "https://skillshub.wtf/HoangNguyen0403/agent-skills-standard/flutter-error-handling?format=md"
SKILL.mdflutter-error-handling

Error Handling

Priority: P1 (HIGH)

Standardized functional error handling using dartz and freezed failures.

Implementation Guidelines

  • Either Pattern: Return Either<Failure, T> from repositories. No exceptions in UI/BLoC.
  • Failures: Define domain-specific failures using @freezed unions.
  • Mapping: Infrastructure catches Exception and returns Left(Failure).
  • Consumption: Use .fold(failure, success) in BLoC to emit corresponding states.
  • Typed Errors: Use left(Failure()) and right(Value()) from Dartz.
  • Low-Cardinality Logging: Use stable message templates; pass variable data via metadata/context.
  • Layer Restriction: try/catch only in Infrastructure. UI/Application should not catch.
  • Failure Mapping: Convert external exceptions with FailureHandler.handleFailure(e).
  • Localization: Use failure.failureMessage (returns TRObject) for UI-safe text.
  • Right/Left Restriction: Only Infrastructure may construct Right()/Left().
  • No Silent Catch: Never swallow errors without logging or a documented retry.

Reference & Examples

For Failure definitions and API error mapping: See references/REFERENCE.md.

Related Topics

layer-based-clean-architecture | bloc-state-management

🚫 Anti-Patterns

  • Do NOT use standard patterns if specific project rules exist.
  • Do NOT ignore error handling or edge cases.

┌ stats

installs/wk0
░░░░░░░░░░
github stars341
██████████
first seenMar 17, 2026
└────────────

┌ repo

HoangNguyen0403/agent-skills-standard
by HoangNguyen0403
└────────────

┌ tags

└────────────