In regular Python, a catch-all exception handler looks like:
try: ... except Exception as exc: # Don't catch KeyboardInterrupt, etc. logger.error(..., exc_info=exc)
In Trio we need to handle MultiError
s, which might contain a mix of exceptions we want to catch and ones we don't, etc. So you have to use MultiError.catch
, and the above becomes:
def handler(exc): if isinstance(exc, Exception): logger.error(..., exc_info=exc) return None # swallow this exception else: return exc # let other exceptions propagate with MultiError.catch(handler): ...
This is pointlessly cumbersome. We should make it look like this:
def handler(exc): logger.error(..., exc_info=exc) with MultiError.catch(Exception, handler): # Note the extra argument ...
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4