a3exception is a package for unifying exceptions during front-end and back-end communication.
Project description
a3exception
English | 简体中文
a3exception is a package for unifying exceptions during front-end and back-end communication.
1. Introduction
errors
- Base exception: Error
- Predefined client exceptions: ValidationError, NotFoundError ...
- Predefined server exceptions: ServerKnownError, ServerUnknownError
DynamicErrorFactory
- Generate a exception dynamically according to the dictionary: build_error_by_status
- Add a custom exception: add_custom_error_cls
2. Usage
Install
pip install a3exception
Examples
from a3exception.dynamic_error_factory import DynamicErrorFactory
from a3exception.errors import Error
class MyError(Error):
def __init__(self, message: str, **kwargs):
super().__init__(message=message, **kwargs)
if __name__ == "__main__":
DynamicErrorFactory.add_custom_error_cls(MyError)
error_message = "custom error"
error = DynamicErrorFactory.build_error_by_status(status=MyError.__name__, message=error_message)
assert isinstance(error, MyError)
assert error.message == error_message
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
a3exception-0.3.0.tar.gz
(4.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file a3exception-0.3.0.tar.gz.
File metadata
- Download URL: a3exception-0.3.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90a1e15bda0523ff87412adcfd396cf6c97136792042d910f06cac5b65591d0c
|
|
| MD5 |
10af7a69c28ba30f184a84f4d2e77217
|
|
| BLAKE2b-256 |
99287ba73997615e3102891b905d5bbd3e9b9c665500ba6cdc544c42f5d58fdb
|
File details
Details for the file a3exception-0.3.0-py3-none-any.whl.
File metadata
- Download URL: a3exception-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60ac7d0db1c7275b83a9f54204874a8ebd1f16cf3d8ea67332862ee9f782deb4
|
|
| MD5 |
5d79b0f1bc12b9662d495d18e3f7ea63
|
|
| BLAKE2b-256 |
c22f31d52fcad65201b36aaa077bf9be5e8ce4e1fee8a8646c8f1afe72c5de39
|