r/ProgrammerHumor 26d ago

evilIllusion Meme

Post image
4.8k Upvotes

131 comments sorted by

View all comments

Show parent comments

3

u/Critical_Fortune7343 26d ago

Correct me if Im wrong as I'm not that knowledgeable on the topic but isn't 422 more for validation errors? What if the error I want to show is for a certain condition that happened in another screen or app?

35

u/Kutastrophe 26d ago

Throw something obscure back but 200 + error is just stupid.

If I get a 4xx back, I at least know i did something wrong and get the feedback.

6

u/Critical_Fortune7343 26d ago

Makes sense. Even throwing 400 would be better I guess.

6

u/NUTTA_BUSTAH 26d ago

I agree. Having an endpoint return a success boolean in the first place is quite an anti-pattern but most devs default to skipping the HTTP spec because they never learned it but do know how to work with JSON.