Structured error handling framework for Python


License
Other
Install
pip install pyerrorschema==1.1.3

Documentation

PyErrorSchema

Installation

The source code is currently hosted on GitHub at here.

Binary installers for the latest released version are available at the Python Package Index (PyPI).

pip install pyerrorschema

Examples

from pyerrorschema import FastAPIErrorSchema

# Creating a error schema
err = FastAPIErrorSchema.database_error(
    loc=["request", "body"],
    input={'data_path': 'test'},
)

# Converting the error to a dictionary and printing it
print(err.to_dict())

This will output:

{'type': 'database_error', 'msg': 'Database operation failed.', 'loc': ['request', 'body'], 'input': {'data_path': 'test'}}