backend · ux · ecowell · database · system-design · reliability

Error Messages That Tell the Truth

2 December 2026 · 2 min read

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.

A cat holds an honest sign beside a robot with a loose plug while a duck points at it

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:

  1. 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.
  2. After the last retry, show the message, the action, and a Retry button.
  3. If not retryable, show the specific message. For form errors, highlight the offending field.
  4. 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

  1. Design the error contract once, and make additions optional so old clients survive.
  2. Use status codes honestly. They are the cheapest monitoring signal you have.
  3. Tell the machine (retryable) and the human (message, action) separately.
  4. A request id on screen turns “it didn’t work” into a one-minute investigation.

AI use: Written with AI assistance from my own notes and project facts, then reviewed by me. Images are AI-generated. How I use AI

Loading reactions…

Working on something similar? Let's talk.

Same problem, a question about this article, a collaboration, or an open-source project you would like me to contribute to. Pick whichever door you like: