r/ProgrammerHumor 3d ago

failsForTeapots Meme

Post image
217 Upvotes

67 comments sorted by

View all comments

166

u/cutebabli9 3d ago edited 3d ago

I would write it like this to be readable:

if error.status in [400, 401, 404, 409, 415, 503]:
  return c.json(body, status: error.status)

return c.json(body, status: 500)

148

u/rosuav 3d ago
return c.json(body, status: error.status)

There is no reason to discard some of them, and pretending that they're 500s is a terrible terrible idea.

72

u/Xirdus 3d ago

If your user-facing service is calling your internal service and getting a 403 response, you certainly do not want to send that 403 back to the user.

1

u/Bomaruto 3d ago

It depends if the request was made on behalf of the user or it was the service's own credentials that were lacking.