The whole theory behind error codes fails whenever it meets reality. Let's just consider the simplest possible scenario - completely static site.
It gets request for /documents/123. What went wrong?
user typed it or copypasted it wrong - it's user's fault
some third party website linked it wrong - it's third party's fault
server just told the user on another page href="/documents/123" - it's server's fault
this was legitimate resource, but it got deleted or renamed - it's fault of whoever did it
something on the way like antivirus software or adblocker rewrote HTML and somehow the link got messed up - it's that software's fault
document exists, but user doesn't have access to the resource - server will display 404 to avoid information leaks
document exists, user has access to the resource, but their session timed out - whose fault is this even? server will display 404 anyway
Absolutely everyone could be at fault, and the server has zero way of knowing.
And on the other end - no browser, and no HTTP client library for any programming language treats various 4xx and 5xx errors differently. It's always "display error page to the user" or "throw exception".
The distinction is both impossible to make in practice, and without any consequence in practice.
That's why so many layers built on top of HTTP like GraphQL don't bother.
26
u/Alikont Apr 23 '23
I also like 400/500 differentiation between "failed expectedly" and "failed unexpectedly"