In other words, should the raising of an HTTP 4xx code be considered an error, and should the job of sending an HTTP 4xx code to a client be delegated to an error handler?
Or is it simpler to just send such codes from whichever local code block we happen to be in, when the need arises, instead of delegating this to an error handler?
I'm leaning towards sending them from local code blocks rather than delegating, since it seems that
- HTTP responses are easy to send, i.e., handle, from a local code block,
- 4xx HTTP codes may not be "real" errors if you use a narrow-enough notion of error,
- the exact HTTP message and code can vary, and it'd be a hassle to account for many such combinations in an error handler.
Thoughts?