Analyst Bootcamp Join on TelegramJoin
Junior+ · Systems Analysis

Error handling: what the user sees, what the log says, what the client does

🕥 9 min read🧭 SA📅 updated 2026-10-15Читать на русском

Every error is three things at once: a message for a person, a code for a program, and a line for whoever is on call. How to design the error list for a feature so that all three are right, and how to write the unhappy paths into the contract.

"Something went wrong"

That message is what a system says when nobody designed its errors. The user cannot act on it, the frontend cannot branch on it, support cannot search for it, and the developer on call finds a stack trace with no request id. Error design is a Junior+ system analyst's job because it sits exactly between the business ("what should the customer do?") and the code ("what should the client do?").

Every error needs three audiences served at once:

AudienceNeedsExample
The personwhat happened, what to do next, in their language"This postcode is not valid for Germany. Check it or choose another country."
The client programa stable code to branch on, and the field it concernscode: postal_code_invalid, field: postalCode
On-call and supporta request id, the time, the inputs that matter, severityreq 7f3a, customer 48213, country DE, postcode 1011

A good error carries all three. A bad one carries a stack trace to the person and a smile to the log.

Step 1: list the errors from the flow

Walk the use case or the sequence diagram and write down every way each step can fail. For "save a delivery address" the list is short and complete:

#FailureWho caused itHTTPCode
E1required field missing or too longclient400validation_failed (+ field)
E2postcode invalid for the countryclient400postal_code_invalid
E3not the customer's own accountclient (or an attack)403forbidden
E4customer not foundclient404customer_not_found
E5sixth addressclient, by rule409address_limit_reached
E6postcode service downdependency503postcode_service_unavailable
E7database errorus500internal_error

Three columns do the work: who caused it decides whether retrying makes sense; the status tells generic HTTP clients what kind of failure it was; the code is what the frontend and the tests use. The code is stable across versions and languages; the message is not.

Step 2: the status is a category, the code is the reason

Use a small set of statuses consistently and stop arguing about the rest:

The rule of thumb the client follows: 4xx means change something before retrying; 5xx means wait and retry; 429 means wait exactly as told. Write that sentence in the API guidelines once, and every integration inherits it.

Step 3: one error shape

The body is the same for every error in the API (RFC 9457, Problem Details, with a small extension for field errors):

{
  "type": "https://api.example.com/problems/address-limit",
  "title": "Address limit reached",
  "status": 409,
  "detail": "You can save up to 5 addresses. Delete one to add another.",
  "code": "address_limit_reached",
  "requestId": "7f3a-2026-10-14",
  "errors": [{ "field": "addresses", "code": "limit", "limit": 5 }]
}

The requestId is the line that connects the person to the log. Support asks the customer for it ("the code at the bottom of the message"), finds the request in thirty seconds, and the on-call developer sees the inputs. Without it, every support escalation starts with "roughly when did this happen?".

One failure, three outputs: a message for the person, a code for the client, a line for the log, all tied by the request id.
One failure, three outputs: a message for the person, a code for the client, a line for the log, all tied by the request id.

Step 4: what the person sees

Messages come from the code, not from the server text. The frontend keeps a table code → message per language, with a fallback for unknown codes ("We could not save the address. Try again in a moment; if it keeps happening, contact support with code 7f3a"). Rules for the messages:

Step 5: what the log says

Each error logs one structured line at the right level. The ticket states the level, because developers will otherwise log everything as ERROR and on-call will mute the channel:

Each line carries the request id, the code, the customer id (not the e-mail), and the input fields that matter, with personal data masked.

Writing it into the contract

Each operation in the OpenAPI document lists its responses (see From a user story to an OpenAPI contract). The error table above is the source: one response per status, with the codes that status can carry in the description, and an example body for each. Acceptance criteria follow: "Given a customer with 5 addresses, When they POST a sixth, Then 409 with code address_limit_reached and no address is created."

With AI

Models produce a decent generic error table and know RFC 9457. They do not know your rules (the limit, the forbidden transitions), your log levels, or your support process (who reads the request id). Use the model for the shape; fill the rows from your use case and decide the levels with the team that gets paged.

Try it (5–10 minutes)

Flow: "Customer redeems a gift card at checkout." Rules: card must exist, be active, not expired, have balance; one card per order; the card issuer's API may be down.

  1. Build the error table: at least seven rows with cause, status, code.
  2. Write the Problem Details body for "card already used on another order", with a requestId and a field error.
  3. Decide the log level and the user message for each of: card expired, issuer API down, duplicate redemption from a retry. Which one is a 409 and why?

Where this shows up in real work

  • System analyst and API designer job posts ask for "error handling design" and "API guidelines"; interviewers hand you an endpoint and ask what it returns when things go wrong.
  • In real teams the error table is what ends the frontend/backend argument about "who shows what"; the request id is what cuts support escalation time in half.
  • Freelance API work: a client who receives an error catalogue with codes and messages stops asking "what does the user see?" in every review.

Sources worth reading

Practice it on real drills

Failure scenarios & error handlingREST API design for a featureRequirements from a production incident

Finished reading and did the exercise?