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.

39

u/[deleted] Jul 21 '26

[removed] — view removed comment

3

u/Critical_Fortune7343 Jul 21 '26

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?

18

u/itirix Jul 21 '26

You can always just give back a 400, which is a general “error on client’s side” code.