Request: ability to remove default error_table mappings in RPC
- 主要語言
- Python
- 星號
- 431
- 分支
- 57
- PR 合併指標
- 30 天內沒有已合併 PR
描述
I want to make custom error reports of the server-side exceptions using all `exc_type`, `exc_args`, and `exc_repr` information (as given to `_translate_error()` in rpc.py).
First I tried giving `error_table` to `connect_rpc()`, but had no luck.
I was going to use the following error_table expecting that all other errors to be translated to `GenericError`...
```python
error_table = {
'aiozmq.rpc.base.NotFoundError': NotFoundError,
'aiozmq.rpc.base.ParametersError': ParametersError,
'asyncio.TimeoutError': asyncio.TimeoutError,
'asyncio.CancelledError': asyncio.CancelledError,
'asyncio.InvalidStateError': asyncio.InvalidStateError,
}
```
The reason is that the current implementation uses `ChainMap` initialized with user-provided error table and the default one, making it *impossible* to *remove* default exception mappings for standard errors while adding/overriding mappings is fine.
Q1: Are there technical reasons to use `ChainMap` and prevent users from overriding exception mappings for standard errors?
Q2: If it was just a design choice, I'd like to request to change it to allow users to specify a whole new error_table or remove existing mappings selectively.
貢獻指南
評估
這個 Issue 還沒有評估資料。