Create custom new exceptions, choose from existing exceptions, raise your custom exceptions and messages, and more!
Project description
pyexcept
The perfect Python 3 library for creating new exceptions, raising custom errors with custom messages and choosing from a set of 13 unique exceptions!
pyexcept Built-in Exceptions
pyexcept contains built-in 13 Exceptions that python BaseException does not include built-in. List:
- BlockageError
- ComileError
- EncodeError
- DecodeError
- HTTPError
- HostResolveError
- IOError
- PermissionError
- RefuseError
- RunError
- TranslationError
- WebConnectionError
- FormatError
Usage example:
INPUT:
import pyexcept
raise pyexcept.PermissionError("This is an example error")
OUTPUT:
Traceback (most recent call last):
File "/home/your_name/exampleFile.py", line 3, in <module>
raise pyexcept.PermissionError("This is an example error")
_.PermissionError: This is an example error
pyexcept Create custom exception
Using the pyexcept module, you can create custom exception names and messages. Example:
INPUT:
import pyexcept
raise pyexcept.newException("MyCustomError", "This is a custom error type, not from BaseException")
OUTPUT:
Traceback (most recent call last):
File "/home/your_name/exampleFile.py", line 3 in <module>
raise pyexcept.newException("MyCustomError", "This is a custom error type, not from BaseException")
_.MyCustomError: This is a custom error type, not from BaseException
pyexception Raise full error
In pyexcept, you can use the raiser() method to create full errors. I will tell exceptions to raise an error that says the error happend on line #1 of "exampleFile.py".
Definition and Usage:
INPUT:
import pyexcept
raise pyexcept.raiser("FullError", "Raise an error", line=1, file="exampleFile.py")
OUTPUT:
Traceback (most recent call last):
File "/home/your_name/exampleFile.py", line 3 in <module>
raise pyexcept.newException("MyCustomError", "This is a custom error type, not from BaseException")
_._:
File "/home/your_name/exampleFile.py", line 1 in <module>
import pyexcept
FullError: Raise an error
Finally, raise errors from BaseException using exceptions
Usage:
INPUT:
import pyexcept
raise pyexcept.base(NameError, "This is an example")
OUTPUT:
Traceback (most recent call last):
File "/home/your_name/exampleFile.py", line 3 in <module>
raise pyexcept.base(NameError, "This is an example")
NameError: This is an example
Thank you!
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
Built Distribution
File details
Details for the file pyexcept-0.0.5.tar.gz
.
File metadata
- Download URL: pyexcept-0.0.5.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2321b8a0aea400f9f1b64588cb8c198d43d27ff43cfa7b78b261fcef48abfbef |
|
MD5 | 7d6db101d1cccb15764035e4bd401d04 |
|
BLAKE2b-256 | 33b251cc5458a8670302163bd7da400e8fc0ad0140bd3a2601e055894b4b7b53 |
File details
Details for the file pyexcept-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: pyexcept-0.0.5-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63d951513f89cc3e725194328575de35ba3ca07a7c70c5b7e01f19b0eb29c58b |
|
MD5 | 50f1bf8ef3e7e47575f8c2994fbd3ffc |
|
BLAKE2b-256 | a6b9234760cc2c66fc0f73b0fdc4c5867d8d6820456ddc8b8a053fc33b22063d |