Used with the ``with`` statement when calling delegate methods to log any exceptions with the given logger. Any exceptions caught are converted to _QuietException
| 47 | |
| 48 | |
| 49 | class _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 | |
| 76 | class HTTP1ConnectionParameters: |
no outgoing calls
no test coverage detected