Decorator error mapper
Project description
Error-mapper
Python error mapper based on decorators.
Installing
pip install error-mapper
Example
Error map
from error_mapper import ErrorMapType, error_map_decorator
class SuppressedError(Exception): ...
class RaiseError(Exception): ...
error_map: ErrorMapType = {
SuppressedError: RaiseError,
}
@error_map_decorator(error_map, RaiseError)
def fn() -> None:
raise SuppressedError
On error execute
from error_mapper import ErrorMapTypeExecute, on_error_execute
class SuppressedError(Exception): ...
class RaiseError(Exception): ...
def process_error(error: Exception) -> tp.NoReturn:
raise RaiseError from error
error_map: ErrorMapTypeExecute = {
SuppressedError: process_error,
}
@on_error_execute(error_map, RaiseError)
def fn() -> None:
raise SuppressedError
Testing, linting, formatting
rye test
rye lint
rye fmt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
error_mapper-1.0.2.tar.gz
(6.7 kB
view hashes)
Built Distribution
Close
Hashes for error_mapper-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a99e91432d81b0286e195afc4352d9cd8ad48d60310ea4d50d17d6daf9e45296 |
|
MD5 | f9ac0691a136c06ed1632946e379b91e |
|
BLAKE2b-256 | fe2728bf4489e64b0c5f743397c18df5a3a7aa31e17808d9d540fef15b1e8507 |