One error shape
Unknown paths, bad parameters, upstream outages and our own bugs all come back the same way. Write the handler once.
- bad_request
- not_found
- method_not_allowed
- too_large
- upstream_timeout
- upstream_error
- internal_error
// Every error, whatever went wrong
type ApiError = {
error: string; // "bad_request", "not_found", …
message: string; // never repeats what you sent
problems?: { field: string; problem: string }[];
};