Stop trying to catch exceptions when its ok to let your program crash

Just found this garbage in our prod code

except Exception as e: logger.error(json.dumps({« reason »: »something unexpected happened », « exception »:str(e)})) return False

This is in an aws lambda that runs as the authorizer in api gateway. Simply letting the lambda crash would be an automatic rejection, which is the desired behavior.

But now the error is obfuscated and I have to modify and rebuild to include more information so I can actually figure out what is going on. And for what? What benefit does catching this exception give? Nothing. Just logging an error that something unexpected happened. Wow great.

and also now I dont get to glance at lambda failures to see if issues are occurring. Now I have to add more assert statements to make sure that a test success is an actual success. Cringe.

stop doing this. let your program crash

submitted by /u/avsaccount to r/Python
[link] [comments]


Commentaires

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *