Skip to content
Mittelware
All posts

The HTTP error codes every frontend should be tested against

Which status codes to simulate, what a good app does for each one, and how to produce them without breaking a real server. A checklist for 401, 403, 404, 429, 500, 502, 503 and timeouts.

The Mittelware team 3 min read

Most apps are tested against 200 and, if you are lucky, a 404. Real users meet the others: expired logins, rate limits, a service that is briefly down, a connection that just stops. This is a checklist of the codes worth simulating, what a good app does for each, and how to produce them.

The checklist#

Status What it means to a user What a good app does
401 Your login expired Refreshes the token once, or sends the user to sign in. Does not loop.
403 You are not allowed Says so clearly. Does not show a blank screen or retry.
404 That thing does not exist Shows a "not found" state. Does not crash on missing data.
409 Someone else changed it Explains the conflict and offers a reload.
422 Some input was invalid Shows the errors next to the right fields.
429 Slow down Waits, using Retry-After if present, and does not hammer harder.
500 Something broke Shows an error and a way to try again.
502 or 503 A service is down or restarting Retries with backoff, then gives up with a message.
Timeout Nothing came back Stops the spinner, lets the user retry, never double-submits.

How to produce each one#

Mittelware has two ways, and which one you need depends on whether the answer needs a body.

Block, for a bare status. A Block rule answers with only a status code, no body and no headers. The Block Action list offers 401, 403, 404, 410, 429, 502 and Timeout (no response).

The Block Action list with seven choices: 401, 403, 404, 410, 429, 502 and Timeout.
Seven choices. Each one exercises a different path through your app.

Modify Response, for a real error body. Anything else, such as 409, 422, 500 or 503, or any error that carries JSON or a header like Retry-After, uses a Modify Response rule. Set Behavior to Instead of the server and fill in the status, headers and body. Because the server is never contacted, it works instantly and offline. See how to simulate a 502 for the step-by-step.

A body matters because most apps read it. A 422 with no field errors will not show you whether your form displays them.

A few cases people forget#

A 429 with Retry-After. Use Modify Response with status 429 and a header Retry-After: 5. Check that the app actually waits five seconds instead of retrying at once.

A lost response. Use Block Response, which lets the request reach the server and then throws the answer away. The server did the work and your app never hears about it. This is how a duplicate order happens in real life, so it is the best test for whether retries are safe.

Failing only some requests. Narrow the rule. Add HTTP Method is POST so reads still work, or match one path, so the rest of the app stays usable while you test one screen.

A slow failure. Add a Delay (ms) so the error arrives after two seconds. A spinner that works for an instant failure can still break when the failure is slow. See test timeouts and slow responses.

Keep it temporary#

A rule that fails requests stays in force until you switch it off. Put your failure rules in their own collection and turn the whole collection on only when you are testing.

Keep reading