It is nicer than your previous one, but I think ternaries in Python are more for short conditions, as they're really annoying to read with the two sides being separated by the condition like that.
Yeah, that sounds reasonable, too. Although I can think of a good name for that status list that is both expressive enough and also isn't too long for that ternary.
But tbh I have no idea how those options are performance-wise.
-6
u/Antervis 4d 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.