返回主题:错误与异常处理机制

知识卡片

普通读书笔记卡 · 1340.f.1.c

错误契约决定如何恢复

理解等级:高级

异常、状态码、错误事件和日志通道都可表达失败,但需约定来源与副作用。错误输入应修正后再发,缺依赖先补齐,暂时失败且操作幂等才适合等待重试;错误状态和错误配置又需不同恢复。只返回“失败”会使调用者不知道是否已经部分完成,无法可靠选择后续动作。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 软件接口 · 查看原书依据

      Temporary errors with idempotent operations can be dealt with by waiting and retrying. Errors due to invalid input require fixing the bad requests and resending them. Missing dependencies should be reinstalled before reattempting to use the interface.

    参考来源

    - 位置:《Software Architecture in Practice, 4th Edition》第15章《软件接口》(来源项目:book-sources;源文件:extracted/Software Architecture in Practice, 4th Edition/_epub-src/ch15.html) - 结论依据:所引连续原文给出本卡机制或取舍;条件与示例结合本节已读上下文解释。 - 原始内容:Temporary errors with idempotent operations can be dealt with by waiting and retrying. Errors due to invalid input require fixing the bad requests and resending them. Missing dependencies should be reinstalled before reattempting to use the interface.