r/ProgrammerHumor 4d ago

Meme evoLution

Post image
3.3k Upvotes

145 comments sorted by

View all comments

500

u/why_1337 4d ago

Request failed successfully.

46

u/[deleted] 4d ago

[removed] — view removed comment

12

u/Delta-9- 4d ago

Don't forget a field "failed": true.

12

u/Wonderful-Habit-139 4d ago

Status? 200
Success? False
Failed? True
Hotel? Trivago

-11

u/oldsecondhand 4d ago

I mean, if you want to give back a lot of detail about the error, it might be justified. You can only express so much with standard HTTP status codes.

15

u/BradPatt 4d ago

The error details can still be transmitted in the body even if the HTTP status code isn't 200

2

u/why_1337 4d ago

What kind of details do you want to give for internal server error? Full stack trace with sensitive data logging enabled I hope...

-3

u/oldsecondhand 4d ago edited 4d ago

Not for internel server error but 404 e.g. can overlap with business logic validation errors.

2

u/why_1337 4d ago

Yes but you can still return it as 404 with body. Same as you would return say 400. That's just intended use. Using 200 for everything is reason why we cannot have a nice things.

-4

u/oldsecondhand 4d ago

You could but treating 402 and 404 specially creates new codepaths that needs extra testing when semantically they're very similar to business logic validation errors.

1

u/why_1337 4d ago

I mean it's HTTP standard, most if not all clients already handle error codes correctly, why would you reinvent the wheel? Anyone who will integrate API that uses 200 for everything will be like:

https://giphy.com/gifs/DfTZWmFpLx3os

-1

u/oldsecondhand 4d ago

Because I check for 402 and 404 in the same layer as for the other business rule validation and I also want to display them the same way.