this post was submitted on 22 Mar 2025
755 points (98.8% liked)

Programmer Humor

22132 readers
1527 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] pupbiru@aussie.zone 6 points 1 week ago* (last edited 1 week ago) (3 children)

error codes aren’t about who’s at fault… you don’t send a 404 because it’s the users or the servers fault. it’s information… a 404 says something doesn’t exist… it’s nobody’s fault; it just is

a 4xx says the request, if tried again without changes or external intervention, is unlikely to succeed

a 5xx says the request might have been fine but some other problem that you can’t control occurred so may be retried without changes at a later time

these are all standard things that are treated in standard ways by generic HTTP libraries… look at, eg axios: a javascript HTTP library that’s often thinly wrapped to build API clients… a 200 is just passed through as success, where 4xx and 5xx will throw an error: exactly what you’d want if you try to retrieve a non-existent object or submit a malformed payload…

this is standard behaviour for a lot of HTTP libraries, and helps people accidentally write better code - an explosion is better than silence for unhandled exceptions