| Conditions | 3 |
| Total Lines | 19 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import logging |
||
| 21 | async def exception_middleware(request: protocol.JsonRpcRequest, handler: typing.Callable) -> protocol.JsonRpcResponse: |
||
| 22 | try: |
||
| 23 | response = await handler(request) |
||
| 24 | except errors.JsonRpcError as e: |
||
| 25 | logging.warning('Unprocessed errors.JsonRpcError', exc_info=True) |
||
| 26 | response = protocol.JsonRpcResponse( |
||
| 27 | msg_id=request.msg_id, |
||
| 28 | jsonrpc=request.jsonrpc, |
||
| 29 | error=e, |
||
| 30 | ) |
||
| 31 | except Exception as e: |
||
| 32 | logger.exception(e) |
||
| 33 | response = protocol.JsonRpcResponse( |
||
| 34 | msg_id=request.msg_id, |
||
| 35 | jsonrpc=request.jsonrpc, |
||
| 36 | error=errors.InternalError().with_traceback(), |
||
| 37 | ) |
||
| 38 | |||
| 39 | return response |
||
| 40 | |||
| 46 |