Skip to main content

Raise exceptions while creating exception classes on the fly, without the need to predefine them beforehand.

Project description

LOGO Release Python Versions License Downloads

gqylpy-exception

English | 中文

Raise exceptions while creating exception classes on the fly, without the need to predefine them beforehand. For instance, if you want to raise an exception named NotUnderstandError, simply import import gqylpy_exception as ge and execute raise ge.NotUnderstandError directly for convenience and efficiency.

pip3 install gqylpy_exception

Using gqylpy_exception to Create Exception Classes
import gqylpy_exception as ge

raise ge.AnError(...)

With gqylpy_exception, you can create exception classes with arbitrary names. AnError is not predefined in gqylpy_exception; it is dynamically created when your code executes ge. due to the magic method __getattr__.

Alternatively, you can also create exceptions upon import:

from gqylpy_exception import AnError

raise AnError(...)

Lastly, gqylpy_exception avoids duplicate creation of exception classes. Once an exception class has been created, it is stored in the ge.__history__ dictionary. When you attempt to create the same exception again, it will be retrieved from this dictionary.

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

gqylpy_exception-3.0.1.tar.gz (11.3 kB view hashes)

Uploaded Source

Built Distribution

gqylpy_exception-3.0.1-py3-none-any.whl (12.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page