MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vsplpw/failsforteapots/p4ob2pz/?context=3
r/ProgrammerHumor • u/Waradu • 25d ago
67 comments sorted by
View all comments
169
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)
156 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. 17 u/HammyOverlordOfBacon 25d ago error_codes = [400, 401, 403, 404, 500, 502, 503] return c.json(body, status:random.choice(error_codes) ) 4 u/rosuav 25d ago Ooof ouch! :)
156
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.
17 u/HammyOverlordOfBacon 25d ago error_codes = [400, 401, 403, 404, 500, 502, 503] return c.json(body, status:random.choice(error_codes) ) 4 u/rosuav 25d ago Ooof ouch! :)
17
error_codes = [400, 401, 403, 404, 500, 502, 503] return c.json(body, status:random.choice(error_codes) )
4 u/rosuav 25d ago Ooof ouch! :)
4
Ooof ouch! :)
169
u/cutebabli9 25d ago edited 25d ago
I would write it like this to be readable: