Manage error codes, descriptions and data in a unified way throughout a project
Project description
============= Error Manager
A lightweight implementation of a manager for error messages throughout your project. Allows you to easily define and register error codes and messages. Enable easy access to a single list of registerd error codes and messages throughout your project.
.. start-badges
.. list-table:: :widths: 8 50 :stub-columns: 1
* - docs
- |docs|
* - tests
- |travis| |requires| |codecov|
* - package
- |version| |wheel| |supported-versions| |commits-since|
.. |docs| image:: https://readthedocs.org/projects/errors/badge/?style=flat :target: https://errors.readthedocs.io/ :alt: Documentation Status
.. |travis| image:: https://api.travis-ci.com/MaartendeRuyter/errors.svg?branch=master :alt: Travis-CI Build Status :target: https://travis-ci.com/github/MaartendeRuyter/errors
.. |requires| image:: https://requires.io/github/MaartendeRuyter/errors/requirements.svg?branch=master :alt: Requirements Status :target: https://requires.io/github/MaartendeRuyter/errors/requirements/?branch=master
.. |codecov| image:: https://codecov.io/gh/MaartendeRuyter/errors/branch/master/graphs/badge.svg?branch=master :alt: Coverage Status :target: https://codecov.io/github/MaartendeRuyter/errors
.. |version| image:: https://img.shields.io/pypi/v/error-manager.svg :alt: PyPI Package latest release :target: https://pypi.org/project/error-manager
.. |wheel| image:: https://img.shields.io/pypi/wheel/error-manager.svg :alt: PyPI Wheel :target: https://pypi.org/project/error-manager
.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/error-manager.svg :alt: Supported versions :target: https://pypi.org/project/error-manager
.. |commits-since| image:: https://img.shields.io/github/commits-since/MaartendeRuyter/errors/v0.1.0.svg :alt: Commits since latest release :target: https://github.com/MaartendeRuyter/errors/compare/v0.1.0...master
.. end-badges
- Free software: GNU Lesser General Public License v3 or later (LGPLv3+)
Installation
::
pip install error-manager
You can also install the in-development version with::
pip install https://github.com/MaartendeRuyter/errors/archive/master.zip
Main usecases
Error manager provides you with a ListErrors
class to retrieve your
custom error codes and descriptions throughout your project::
# retrieve customer defined ErrorCode object form ``ListErrors`` class
>>> from errors import ListErrors
>>> error = ListErrors.COULD_NOT_FIND_ERROR_CODE
>>> error
ErrorCode(code='ER_GETERROR_00001', description='Could not find requested
error code', error_data=<class 'dict'>)
# add custom error data to error message when you want to persist or log
# the error
>>> from errors import add_error_data
>>> error_with_data = add_error_data(error, {'key': 'Example error data'})
>>> error_with_data
ErrorCode(code='ER_GETERROR_00001', description='Could not find requested error code', error_data={'key': 'Example error data'})
Documentation
https://errors.readthedocs.io/
Changelog
1.3.2 (2023-10-23)
- Added support for python 3.12
1.3.1 (2023-10-20)
- Refactored setup.cfg and pyproject.toml
1.3.0 (2022-11-01)
- Added type annotations
1.2.4 (2022-10-26)
- Added support for python 3.11
1.2.2 (2022-05-09)
- Added
ReturnValueWithErrorStatus
to init for easy import.
1.2.1 (2022-05-08)
- Added a class
ReturnValueWithErrorStatus
to easily createReturnValueWithStatus
with a error attached to it.
1.2.0 (2022-05-06)
- Added a dataclass
ReturnValueWithStatus
to allow consuming classes and methods to return a single return type with result, status and errors collected in one Object
1.1.1 (2021-11-06)
- Import
ListErrors
,ErrorCode
,add_error_data()
andis_error()
inerrors
__init__.py
so that they can be directly imported fromerrors
module
1.1.0 (2021-11-05)
- Added is_error method to check if an object is an instance of
(sub)class
ErrorCode
1.0.0 (2021-10-12)
- Added Documentation and removed more default but redundant Documentation
- Added reference documentation for
ListErrors
andbase
module
0.9.0 (2021-10-11)
-
added error codes as attribut to ListErrors class. After registration of an ErrorCode the errorcode is accessible in
ListErrors
via::ListErrors.ERROR_CODE_KEY
-
Added Documentation and removed default redundant Documentation
0.1.0 (2021-10-08)
- First release on PyPI.
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
Built Distribution
Hashes for error_manager-1.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b2107f7d997af5ea48b74622691b27384e2ff0c6c4f33d70eb191c46113bd22 |
|
MD5 | b9462f6fc156418bc0db7d110a0ec420 |
|
BLAKE2b-256 | 7b6a7b2a318125f78a808460140ee4f6cf170d9093cc0331faec997809c96fe2 |