MCPcopy
hub / github.com/tornadoweb/tornado / _ExceptionLoggingContext

Class _ExceptionLoggingContext

tornado/http1connection.py:49–73  ·  view source on GitHub ↗

Used with the ``with`` statement when calling delegate methods to log any exceptions with the given logger. Any exceptions caught are converted to _QuietException

Source from the content-addressed store, hash-verified

47
48
49class _ExceptionLoggingContext:
50 """Used with the ``with`` statement when calling delegate methods to
51 log any exceptions with the given logger. Any exceptions caught are
52 converted to _QuietException
53 """
54
55 def __init__(self, logger: logging.Logger) -> None:
56 self.logger = logger
57
58 def __enter__(self) -> None:
59 pass
60
61 def __exit__(
62 self,
63 typ: "Optional[Type[BaseException]]",
64 value: Optional[BaseException],
65 tb: types.TracebackType,
66 ) -> None:
67 if value is not None:
68 assert typ is not None
69 # Let HTTPInputError pass through to higher-level handler
70 if isinstance(value, httputil.HTTPInputError):
71 return None
72 self.logger.error("Uncaught exception", exc_info=(typ, value, tb))
73 raise _QuietException
74
75
76class HTTP1ConnectionParameters:

Callers 4

_read_messageMethod · 0.85
_read_fixed_bodyMethod · 0.85
_read_chunked_bodyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected