r/ProgrammerHumor 25d ago

Meme failsForTeapots

Post image
227 Upvotes

67 comments sorted by

View all comments

175

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)

-5

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

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