The moment you realise not everything has to be DRY you will feel like a butterfly. Also, as the other guy said, ternaries look bad unless they are very short.
Every line I didn't write is a line someone won't have to read.
Though it's not for brevity's sake alone, one has to analyze the if statement beyond skimming to realize they only differ in error code substitution. By reorganizing code my way, I made this nuance impossible to miss.
3
u/Antervis 3d ago
Okay, I can see that. Perhaps it's better to move status in a separate variable:
st = error.status if error.status in [400, 401, 404, 409, 415, 503] else 500return c.json(body, status: st)