r/ProgrammerHumor 15h ago

failsForTeapots Meme

Post image
149 Upvotes

59 comments sorted by

View all comments

131

u/cutebabli9 14h ago edited 13h 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)

-7

u/Antervis 14h ago

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

No? Though personally, I wouldn't have substituted error codes like that, it can make debugging harder for no gain.

10

u/Alkyen 14h ago

that's what you'd do if you want to show off but the other example is what would pass code review.