Error Codes
Overview
HTTP and runtime errors are signals about which layer failed and what to inspect next.
Why It Matters
Correctly classifying an error saves time and prevents random guessing across the stack.
Core Concepts
2xxoften means the UI or state layer is the problem.4xxusually means request, auth, validation, or permissions.5xxusually means backend, infrastructure, or dependency failure.
Mental Models
Start with the code, then ask which boundary it describes.
Best Practices
- Read the response payload, not just the status code.
- Pair the code with the request URL and method.
- Check retries and caching when a response looks stale.
Common Mistakes
- Treating every
500as the same issue. - Assuming
404always means a bad client route. - Ignoring redirects in auth and middleware flows.
Trade-offs
Error codes are a fast heuristic, but they are not the whole diagnosis. Use them to point investigation, not replace it.
Decision Framework
| Code range | Usually means | First check |
|---|---|---|
2xx | UI or state issue | Rendering and data mapping |
4xx | Client or auth issue | Payload, auth, validation |
5xx | Server issue | Logs, dependencies, infra |
Examples
422means validation failed, usually in forms or API input.429means rate limiting, retry policy, or abuse protection.504means timeout, often a dependency problem.
Checklists
- Did I capture method, URL, status, and payload?
- Is the failure consistent or intermittent?
- Which layer owns the failure?
Senior Engineer Notes
Senior engineers use codes as a triage tool and move quickly to the right boundary instead of reading the same failure five times.