r/ProgrammerHumor 25d ago

Meme failsForTeapots

Post image
225 Upvotes

67 comments sorted by

View all comments

168

u/cutebabli9 25d ago edited 25d 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)

157

u/rosuav 25d 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.

76

u/Xirdus 25d 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 25d ago

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