Re:Postmodern Error Handling in Python 3.6
by kstrauser on Saturday February 25, 2017 @03:17PM
(#13733599)
My pattern on this stuff is to initially write:
try:
do_something()
except ExpectedException:
handle_it()
except OtherKnownException:
handle_that_too()
except Exception as exc:
log.exception('New kind of error just happened')
handle_fallback()
Re:Postmodern Error Handling in Python 3.6
by greglindahl on Saturday February 25, 2017 @04:32PM
(#13733960)
Yes, that's basically what I'm doing.
except (aiohttp.ClientError, aiohttp.DisconnectedError, aiohttp.HttpProcessingError, aiodns.error.DNSError, asyncio.TimeoutError, RuntimeError) as e:
I want to continue running no matter what, so I also have an "except Exception", but I have better logging now that I know what the known vs. unknown exceptions are.