Gate: api-errors-declared
Every error response of an API unit carries its error code and message, under a status its Responses declare.
| Property | Value |
|---|---|
| Checker | api-errors-declared |
| Confronts | code |
| Blocking by default — new project | yes |
| Blocking by default — existing project | no — informs |
How it measures
Section titled “How it measures”An API spec ties three things the client relies on: which contract each body is, which status each refusal answers with, and which error code and message come with it. Three gates ask whether the spec holds them together, before anything is compiled or run:
| Gate | Question |
|---|---|
api-contracts-resolve |
Is every contract the body and the responses cite a spec with a Domain, and does every response say its contract? |
api-errors-declared |
Does every error response carry its error code and message, under a status the Responses declare? |
error-codes-honored |
Is every error code the spec declares one the unit’s code emits? |
The OpenAPI build already fails on a contract that is no spec; asked here, per unit, the failure names
the unit while it is being written, and the pre-commit stops the commit that broke it. They run on an
API unit’s main code file — the layers tagged interface — and read the spec beside it, when it has an
Endpoint section; sections and their columns are read in any language of the catalog.
Declaring it
Section titled “Declaring it”gates: - name: api-errors-declared on: [code] check: api-errors-declared