Error contracts

← 开发理念

文章目前提供英语和俄语版本。以下显示英语版本。

Preserve meaning across boundaries

failure → explicit error contract → upper-level handler → user-visible result

Expected failures such as validation, missing data or API rejection use the existing result contract. Broken invariants, malformed responses and programming errors must not become empty data or fake success.

Infrastructure reports the failure; domain or application code interprets it; an upper boundary chooses presentation. Logging alone is not handling. Preserve the original cause when transforming an error.

A missing CMS page remains 404. Unavailable required infrastructure is a server failure. Test both the contract and the resulting user-visible behavior, including retry and data preservation.