A page loads /api/questions using fetch inside a try/catch block. A 404 response does not enter catch unless JSON parsing also fails. How should HTTP errors be handled separately from network and parsing errors?
Editorial starter question from DevCircle, provided for learning and discussion.
Network failures, cancellation, and invalid JSON can also throw. Handle these in the caller and display a useful retry state. If an endpoint returns 204 No Content, do not call json() for that response. Parse documented error payloads separately and avoid exposing raw server responses in the UI.