Failures
Your code says what went wrong, by name, and Jadpo decides how each failure reaches whoever called: the HTTP status, the response body and what is logged. Code never throws, never picks an HTTP status and never builds an error response.
Three kinds of thing can go wrong, and only the first is yours to declare:
- A domain failure is an outcome your app expects, such as a todo that doesn't exist. You declare it and say where it can happen.
- A fault is a problem outside your code: the database is down, a provider timed out, or a write may or may not have been saved. The runtime raises it.
- A defect is a bug: a number overflowed, the recursion limit was reached, or the compiler got something wrong. The runtime raises it too.
| Declared by | Listed in fails |
The client sees | The log gets | |
|---|---|---|---|---|
Domain failure, such as TodoNotFound |
you, as type X = Failure |
yes | its code, message and client fields | its code, where it was raised, the path it travelled and its internal fields |
| Fault, such as the database being down | the runtime | no | a fixed code for that fault | the cause chain |
| Defect, such as an overflow | the runtime | no | internal_fault |
the cause and stack |
Markdown for agents: /docs/failures.md.Built from Jadpo main at a707efb.