首页/ AI 技能 / @skilllib/skill-2014279426685480963
Skill站外收录 @skilllib/skill-2014279426685480963

error-handling

采用函数式编程范式实现统一错误处理,通过不可变的失败类型和 Either 结构分离成功与失败路径,确保 UI 层不抛异常,所有错误在领域层被明确建模并安全传递至状态管理组件。

0.0 (0) 135 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

# 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`. ## Reference & Examples For Failure definitions and API error mapping: See [references/REFERENCE.md](references/REFERENCE.md). ## Related Topics layer-based-clean-architecture | bloc-state-management

评论 0

还没有评论,来抢沙发。