this post was submitted on 22 Mar 2025
758 points (99.0% liked)

Programmer Humor

22115 readers
848 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
 
top 50 comments
sorted by: hot top controversial new old
[–] [email protected] -1 points 4 days ago

This is a good practice tho. The HTTP code describes the status of the HTTP operation. Did the server handle it? No? Was the url not found? Did it time out? Was the payload too large? And the JSON describes the result of the backend operation. So 200 OK with error: true means that your HTTP request was all good, but the actual operation bugged out for whatever reason. If you try to indicate errors in the backend with a HTTP error code, you quickly get confused about which codes can happen for what reason.

[–] [email protected] 2 points 1 week ago

You can put anything in your dialog box

[–] [email protected] 28 points 1 week ago
HTTP 200
{"status": "success", "payload": "{\"error\": true}"}
[–] [email protected] 28 points 1 week ago

Ah, the 200 Go Fuck Yourself pattern.

I use HTTP error codes in my API, and still occasionally see a GET /resource/{"error":"invalid branchID provided"} from people who don't seem to know what they are.

[–] [email protected] 3 points 1 week ago (1 children)

me with gRPC error codes: nil, parameter error, app error -- OK, you fucked up, we fucked up. Edit: forgot NotFound.

I really should read about the various ones that exist at some point, but I've always got bigger fires to put out.

Edit, since it seems unclear, gRPC != HTTP and does not use the same status codes. I meant that I felt like I was using fewer than I should, though I just checked and basically not.

[–] [email protected] 9 points 1 week ago (2 children)

This is basically the difference between HTTP 4xx and 5xx error codes. 4xx means the client did something wrong (invalid request, tried to load something that doesn't exist, doesn't have access), whereas 5xx means the request was OK but something broke on the server.

[–] [email protected] 3 points 1 week ago (1 children)

Yeah, I know how http status codes work. I just followed the existing pattern at my current place with gRPC and this post made me realize I don't know most gRPC error codes and best practices.

[–] [email protected] 1 points 1 week ago (1 children)

The way you phrased it made it sound like you definitely don't

[–] [email protected] 1 points 1 week ago

gRPC does not use HTTP status codes. I meant that I might be making a similar mistake with gRPC status codes though, after checking just now, not so much (there are only 17 total codes, not all of which apply to my APIs).

[–] [email protected] 9 points 1 week ago

I always loved how Sierra took its error message and turned it into an intentionally quitting the game message because every time they closed the game, instead of closing properly it crashed.

[–] [email protected] 12 points 1 week 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] 21 points 1 week 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 1 week 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 1 week 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.

[–] [email protected] 12 points 1 week ago

Someone GraphQLs

[–] [email protected] 17 points 1 week ago

Several Favicon APIs do this. Even Google's Favicon endpoint does it, because they return a fallback image. It's pretty annoying.

load more comments
view more: next ›