02-daily-development

Error Codes

02-daily-development/error-codes

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

  • 2xx often means the UI or state layer is the problem.
  • 4xx usually means request, auth, validation, or permissions.
  • 5xx usually 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 500 as the same issue.
  • Assuming 404 always 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 rangeUsually meansFirst check
2xxUI or state issueRendering and data mapping
4xxClient or auth issuePayload, auth, validation
5xxServer issueLogs, dependencies, infra

Examples

  • 422 means validation failed, usually in forms or API input.
  • 429 means rate limiting, retry policy, or abuse protection.
  • 504 means 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.


Further Reading