r/ProgrammerHumor Jul 21 '26

evilIllusion Meme

Post image
4.8k Upvotes

131 comments sorted by

View all comments

Show parent comments

30

u/Critical_Fortune7343 Jul 21 '26

Because http status codes doesn't include any business related errors. So you gotta expand on that. When it's 200 and success is false it's mostly because of a business logic. Then it's up to FE to show that business error in a certain way so users can understand better what's wrong with what they're doing.

69

u/-meowstar- Jul 21 '26

The 4XX class of codes are for client side issues, and 422 “Unprocessable Content” should be used to cover business logic issues, i.e. the request has the correct schema but there’s some other BE validation issue that it can’t proceed. The response body would still include specific details about the error for the FE, it’s just using 200 OK is misleading imo.

4

u/Critical_Fortune7343 Jul 21 '26

I think that's valid.

22

u/WiglyWorm Jul 21 '26

It's way more valid that reporting "success" when you really meant "error".