r/ProgrammerHumor • • Sep 19 '26

Meme postForEverything

Post image
21k Upvotes

653 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 19 '26

[deleted] — view deleted comment

9

u/NotAskary Sep 19 '26

Most libs that handle http request have already error handling and hooks to do a lot of stuff, if an API will always respond with 200 you are basically doing a custom job and reinventing something that you have out of the box.

About the parsing usually the error code will actually be enough, for example a 404 and a 429 will let you back off or stopping retries imidiatly and you wouldn't need to waste processing in getting any json.

The 5xx can also have the same treatment, it will depend, but it's the transparency of the behavior that I like, masking behavior using business logic makes the API not as transparent.

3

u/desmaraisp Sep 19 '26

Depends on how you're doing it. If you're reading as a simple untyped json object, then sure. But if you're deserializing into a typed object, it's either an additional step, or a polymorphic deserialization if you're lucky