backend · ux · ecowell · database · system-design · reliability
Error Messages That Tell the Truth
Most apps fail the same way: a generic “Something went wrong” for everything, from a typo in a form to a database outage. Users cannot fix it, support cannot trace it, and the app cannot know whether retrying would help. We replaced that with one contract, used by the backend and every portal.

One shape for every error
{
"success": false,
"requestId": "uuid",
"error": {
"code": "QUEUE_BUSY",
"message": "Lots of people are using EcoWell right now.",
"action": "We'll retry automatically. You can also tap Retry.",
"retryable": true,
"retryAfterMs": 2000,
"field": null
}
}
It was designed to be backward compatible. success, requestId, code and message stayed exactly as they were, so old clients keep working. The new fields (action, retryable, retryAfterMs, field) are optional extras.
Status codes name the real cause
| Code | Meaning |
|---|---|
| 400 | Invalid input. field says which one. |
| 401 | Session expired. |
| 403 | Not allowed. The message names who can do it. |
| 404 | Not found. |
| 409 | Conflict or stale version. |
| 429 | Rate limited. Retryable. |
| 503 | Busy or upstream down. Retryable. |
| 500 | A real bug. Not retryable. |
Two rules matter most: never 503 for not-found or forbidden, and never 500 for bad input. A 500 should mean “we have a bug”, and if every problem is a 500, nobody can tell the signal from the noise. Retry-After mirrors retryAfterMs for standard clients.
The requestId is the support tool
Every error is logged on the server with the request id, code, route, actor and underlying cause (stack or database error), never secrets or personal values. The portal shows a small “Ref: …” line. When a user reads it out, support finds the exact failure in seconds.
Portals act on retryable
One small API client helper per portal does the same thing:
- If
retryable, retry automatically after 1 s, 2 s, 4 s (with jitter, max 3), while showing “Lots of people are using EcoWell right now. Trying again…” inside the existing loader. - After the last retry, show the
message, theaction, and a Retry button. - If not retryable, show the specific message. For form errors, highlight the offending
field. - Never show a generic message when a specific one exists.
This pairs with the Good Queue gateway: when the queue is full it answers 503 QUEUE_BUSY quickly, and the portal turns that into a calm automatic retry instead of a red error.
Takeaways
- Design the error contract once, and make additions optional so old clients survive.
- Use status codes honestly. They are the cheapest monitoring signal you have.
- Tell the machine (
retryable) and the human (message,action) separately. - A request id on screen turns “it didn’t work” into a one-minute investigation.