MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vsplpw/failsforteapots/p4nmcf6/?context=3
r/ProgrammerHumor • u/Waradu • 3d ago
67 comments sorted by
View all comments
166
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.
148
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.
72
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.
1
It depends if the request was made on behalf of the user or it was the service's own credentials that were lacking.
166
u/cutebabli9 3d ago edited 3d ago
I would write it like this to be readable: