this post was submitted on 22 Mar 2025
761 points (100.0% liked)

Programmer Humor

21988 readers
1215 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
[–] [email protected] 14 points 6 days ago (1 children)

Here I am preferring 200, with success boolean / message string...

Iike HTTP errors codes for real fuck up's, if I see 500 somethings fucked in the app, otherwise a standardised json response body seems way easier

[–] [email protected] 20 points 6 days ago (1 children)

What about both? User supplies bad input? HTTP 400 with response body json describing the error in a standard format?

[–] [email protected] 7 points 6 days ago (1 children)

when you are too lazy to ask your request library to not throw exception on non-200 responses.

[–] [email protected] 5 points 6 days ago

Throwing exceptions is fine since errors are an exceptional circumstance (not expected during normal use of the app), and you probably want errors to follow a different code path so that they can be logged, alerts triggered if needed, etc.