Sub topic 6
Kinds of errors users meet
This chapter assumes you know basic UI vocabulary (layout, components, copy), how web or mobile apps fetch data asynchronously, and can read simple HTML and TypeScript. The previous chapters covered loading and empty states. Here you will sort errors into kinds, because the kind decides the message, the recovery action, and where on the screen the error appears. Chapters that follow cover the wording and the recovery paths in detail.
Why classify errors at all
A screen that shows "Something went wrong" for every failure treats a mistyped email, an expired session, a dropped Wi-Fi connection, and a crashed server as the same event. They are not. Each has a different cause, a different person who can fix it, and a different next step.
Classification gives you three things:
- A message that fits. "Enter a valid email address" and "Our servers are having trouble" cannot be swapped.
- A recovery action that fits. Retrying a validation error never helps. Retrying a timeout often does.
- A location that fits. A field error belongs beside the field. A failed page load belongs in place of the content.
You can classify along four questions: what caused it, who can fix it, whether retrying helps, and how much of the screen it affects.
Classify by cause
Validation errors
The user supplied input the system cannot accept: a required field left blank, a password that is too short, a date in the past. The user can fix this immediately, and retrying without changes always fails. These usually map to HTTP 400 or 422, or are caught by client-side checks before any request is sent.
Design implication: show the error next to the field, keep everything the user typed, and move attention to the first invalid field.
Authentication errors
The system does not know who the user is, or no longer does. A session expired, a token was revoked, or the user never signed in. The usual signal is HTTP 401.
Design implication: send the user to sign in and return them to where they were afterward. Preserve unsaved work if you can. Losing a half-written form to a session timeout is the worst version of this error.
Permission errors
The system knows who the user is, but they are not allowed to do this. The usual signal is HTTP 403. The user cannot fix it alone. Someone else, such as an admin or the resource owner, must grant access.
Design implication: say that access is the problem and name who can grant it, if you know. Do not offer a Retry button, because retrying cannot change the answer.
Not-found errors
The thing the user asked for does not exist, or was deleted, or moved. The usual signal is HTTP 404. This is different from an empty state. An empty list is a successful request that returned zero items. A missing resource is a request that failed because the target is absent.
Design implication: explain that the item is gone or the link is wrong, and offer a path to somewhere useful, such as the parent list or search.
Conflict errors
The request is valid, but it clashes with the current state of the data. Two people edited the same record, a username is taken, or an item was already purchased. The usual signal is HTTP 409 or 412.
Design implication: show what conflicts and let the user resolve it, for example by choosing which version to keep.
Rate-limit and quota errors
The user, or the app on their behalf, has made too many requests or used up an allowance. The usual signal is HTTP 429, often with a Retry-After header. Retrying works after a wait, not immediately.
Design implication: tell the user to wait, and if the server says how long, show that time. Disable the action briefly instead of letting the user hammer the button.
Connectivity errors
The request never reached the server or no response came back. The device is offline, the connection dropped, DNS failed, or the request timed out. In browsers, fetch rejects with a TypeError for network failures. There is no HTTP status because there was no response.
Design implication: blame the connection, not the user or the product, and offer Retry. If the app supports offline use, queue the action instead.
Server errors
The server received the request and failed to handle it: HTTP 500, 502, 503, or 504. The user cannot fix it. Retrying sometimes works, especially for 502, 503, and 504, which often reflect temporary overload or a deployment in progress.
Design implication: take responsibility in the message, offer Retry with a reasonable limit, and avoid exposing stack traces or internal codes as the main text. A short reference ID that support can look up is useful in smaller type.
Client bugs and unexpected failures
Your own code throws: a null value where data was expected, a response shape the app did not anticipate, a rendering exception. The user did nothing wrong and the server may be healthy. Nothing in the response tells you what to say.
Design implication: catch these at a boundary so one broken component does not blank the whole app, show a generic fallback, and log the details for developers. This is the only place where a generic message is acceptable, because you honestly do not know the cause.
Summary table
| Kind | Typical signal | Who can fix it | Does retry help? | Usual scope |
|---|---|---|---|---|
| Validation | 400, 422, client check | User | Only after editing input | Field |
| Authentication | 401 | User (sign in) | After signing in | Page or app |
| Permission | 403 | Another person | No | Page or region |
| Not found | 404 | Nobody, or the user via a new link | No | Page or region |
| Conflict | 409, 412 | User, by resolving the clash | After resolving | Region or form |
| Rate limit | 429 | Time | After waiting | Action |
| Connectivity | Rejected fetch, timeout | User's network | Yes | Page, region, or action |
| Server | 500, 502, 503, 504 | The team | Sometimes | Page or region |
| Client bug | Thrown exception | The team | Rarely | Component |
Classify by scope
Scope is how much of the screen the error affects. It decides where the error appears.
- Field: one input is wrong. Show the message beside it.
- Action: one button press failed, such as Save or Delete. Show the message near the button or as a transient notice, and keep the rest of the screen usable.
- Region: one panel failed to load while others succeeded. Replace only that panel with an inline error.
- Page: the main content of the screen could not load. Replace the content area with an error state.
- App: nothing can work, for example the session is gone or the service is down. Use a full-screen state.
Use the smallest scope that is accurate. A page-level error for a failure in one widget hides content the user could still use. The chapter on retry, fallback, and partial failure returns to this.
Classify by retryability and ownership
Two attributes drive most recovery decisions, and they are worth storing in your error model instead of rederiving in each component.
- Retryable: would sending the same request again plausibly succeed? Connectivity, rate limit (after a wait), and many server errors are retryable. Validation, permission, and not found are not.
- User-fixable: can the user do something about it? Validation and authentication are. Server errors are not.
These combine into four cases. Retryable and not user-fixable (a 503) gets a Retry button. Not retryable and user-fixable (validation) gets guidance to edit. Neither (a 403) gets an explanation and a pointer to the person who can help. Both (an offline device the user can reconnect) gets a hint plus Retry.
Putting the classification in code
The TypeScript below turns an HTTP status or a thrown failure into a structured description that a UI can render consistently. It runs as shown in a recent Node.js or in a browser console.
type ErrorKind =
| "validation"
| "unauthenticated"
| "forbidden"
| "not_found"
| "conflict"
| "rate_limited"
| "offline"
| "timeout"
| "server"
| "unknown";
type Scope = "field" | "action" | "region" | "page";
interface ClassifiedError {
kind: ErrorKind;
retryable: boolean;
userCanFix: boolean;
scope: Scope;
}
function classifyStatus(status: number): ClassifiedError {
switch (true) {
case status === 400 || status === 422:
return { kind: "validation", retryable: false, userCanFix: true, scope: "field" };
case status === 401:
return { kind: "unauthenticated", retryable: false, userCanFix: true, scope: "page" };
case status === 403:
return { kind: "forbidden", retryable: false, userCanFix: false, scope: "region" };
case status === 404:
return { kind: "not_found", retryable: false, userCanFix: false, scope: "page" };
case status === 409 || status === 412:
return { kind: "conflict", retryable: false, userCanFix: true, scope: "action" };
case status === 429:
return { kind: "rate_limited", retryable: true, userCanFix: false, scope: "action" };
case status >= 500 && status <= 599:
return { kind: "server", retryable: true, userCanFix: false, scope: "region" };
default:
return { kind: "unknown", retryable: false, userCanFix: false, scope: "region" };
}
}
function classifyFailure(err: unknown): ClassifiedError {
if (err instanceof DOMException && err.name === "AbortError") {
return { kind: "timeout", retryable: true, userCanFix: false, scope: "region" };
}
if (err instanceof TypeError) {
// fetch rejects with TypeError when no response arrives.
return { kind: "offline", retryable: true, userCanFix: true, scope: "region" };
}
return { kind: "unknown", retryable: false, userCanFix: false, scope: "region" };
}
console.log(classifyStatus(422));
console.log(classifyStatus(503));
console.log(classifyFailure(new TypeError("Failed to fetch")));Notice that the classifier decides facts, not wording. The message text comes later, in the next chapter, and can then depend on kind without each component having to inspect status codes.
Edge cases and common mistakes
- Empty versus not found. A search with no results is an empty state. A request for
/projects/99that returns 404 is an error. Mixing them leads to messages like "No projects found" for a deleted project, which misleads people. - 401 versus 403. Treating both as "access denied" sends signed-out users to a dead end when signing in would fix it. Treating both as "please sign in" loops signed-in users who lack permission.
- Retrying non-idempotent actions. An automatic retry of a payment or a message send after a timeout may duplicate it, because the first request may have succeeded. Only retry automatically when the action is safe to repeat, or when the server supports an idempotency key.
- Server errors blamed on the user. A message such as "Invalid request" for a 500 sends users hunting for a mistake they did not make.
- Hiding partial failure. If one of four panels fails, a page-level error throws away three working panels.
- Errors that look like content. A failed image or avatar replaced by a blank box looks like missing data. Give failures a visible, distinct treatment.
- Mapping every unknown status to "server". Unexpected 3xx or odd 4xx codes usually point to a proxy, a redirect, or a bug on your side. Keep an "unknown" kind so you do not misreport them.
Checklist for your own screens
- List every request the screen makes, including saves and deletes, not only the initial load.
- For each request, write down which of the kinds above can occur.
- For each kind, record its scope, whether it is retryable, and whether the user can fix it.
- Decide where each error appears so that the smallest accurate area is affected.
- Confirm the code distinguishes these kinds by status or code, not by message text.
Exercise
A user opens a project page. The project list panel loads fine, but the activity feed panel returns HTTP 503. Separately, when the user tries to rename the project, the server returns HTTP 409 because a teammate renamed it a moment earlier. Classify each failure by kind, scope, retryability, and whether the user can fix it, and say where each error should appear.
Show answer
The activity feed failure is a server error. Its scope is the region (the feed panel only), it is retryable, and the user cannot fix it. Show an inline error with a Retry button inside the feed panel and leave the project list and the rest of the page working. The rename failure is a conflict error. Its scope is the action (the rename form), it is not retryable as-is, and the user can fix it by resolving the clash. Show the message near the rename control, display the teammate's new name, and let the user choose to keep their name or accept the new one. Neither failure should replace the whole page.
Exercise
Your app currently shows "Access denied" with a Retry button for both HTTP 401 and HTTP 403. Explain why this is a problem for each status, and describe the better treatment for each.
Show answer
For 401 the user is not signed in or their session expired, so "Access denied" is confusing and Retry fails until they sign in. The better treatment is to send them to sign in and return them to the same place, preserving unsaved work. For 403 the user is signed in but lacks permission, so Retry can never succeed. The better treatment is to explain that they do not have access, name who can grant it if known, and remove the Retry button.