Briefle words · Code & architecture
Error envelope
A fixed wrapper that every error response uses, so clients always know where to find the details.
Say it to an AI
Add one error-handling middleware for the payments API so every endpoint returns the same error envelope: {"error": {"code", "message", "field?"}} with a stable snake_case error code and the right 4xx status. Route handlers throw typed errors; only the middleware formats responses.
How an expert would brief the stronger version of “Payment API errors”.
See it
Try it as a puzzle →A developer tests how a payments API responds to three different bad requests.
Why: A always returns {"error": {"code", "message"}}; B makes "error" a string in one response, an object in the next and switches to an "errors" array in the third.
Related words
Room 5 · APIs & data
Learn “Error envelope” in a five-minute lesson