Skip to main content

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:

  1. BlockageError
  2. ComileError
  3. EncodeError
  4. DecodeError
  5. HTTPError
  6. HostResolveError
  7. IOError
  8. PermissionError
  9. RefuseError
  10. RunError
  11. TranslationError
  12. WebConnectionError
  13. 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!

Now, please visit my github account here!

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

pyexcept-0.0.1.tar.gz (14.7 kB view hashes)

Uploaded Source

Built Distribution

pyexcept-0.0.1-py3-none-any.whl (15.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