aio-libs / aio-libs/aiozmq

Request: ability to remove default error_table mappings in RPC

Offen
#91 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
431
Forks
57
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.