Skip to main content

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

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

a3exception-0.3.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

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

Hashes for a3exception-0.3.0.tar.gz
Algorithm Hash digest
SHA256 90a1e15bda0523ff87412adcfd396cf6c97136792042d910f06cac5b65591d0c
MD5 10af7a69c28ba30f184a84f4d2e77217
BLAKE2b-256 99287ba73997615e3102891b905d5bbd3e9b9c665500ba6cdc544c42f5d58fdb

See more details on using hashes here.

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

Hashes for a3exception-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 60ac7d0db1c7275b83a9f54204874a8ebd1f16cf3d8ea67332862ee9f782deb4
MD5 5d79b0f1bc12b9662d495d18e3f7ea63
BLAKE2b-256 c22f31d52fcad65201b36aaa077bf9be5e8ce4e1fee8a8646c8f1afe72c5de39

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.1

1 file

0.1.0

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page