3 ms·
try: do_something_complex(*args, **kwargs) except MyException as ex: logger.log(ex) Basically this method is a giant @TODO, which does make
by munro 5y ago
try:
do_something_complex(*args, **kwargs)
except MyException as ex:
logger.log(ex)
Basically this method is a giant @TODO, which does make sense in some cases. Either it's unknown at the present moment what a piece of data will look like (like scraping, or some poorly undocumented API); or the developer just doesn't have enough time and will deal with it later, which you can laugh at, but it can make a lot of sense when looking at the higher level goals of the project, our time is limited.
I usually do this at the top level of a batch job, where you don't want it to halt the entire job. Or for a GUI app, but then also launch some sort of notification to the user / reload the app. Basically whatever makes the most sense in the context for accounting for something you didn't account for.