Skip to main content

Create your custom errors and I have control of them with Custom Error

Project description

Custom Error

Script to throw custom errors in Python

Create your custom errors and I have control of them with Custom Error

Use

'''
Test of the module Custome Error
'''
from custom_error import Error

if __name__ == '__main__':
    try:
        number:float = -0.2

        if number < 0.0 or number > 1.0:
            raise Error("Only ranges between 0.0 and 1.0 are allowed", "Invalid Range")
    except Error as e:
        print(e.info())

Sintax

Error(message:str, type_error:str = '')

type_error (str): Type of the error (optional).
message (str): Error message (defaults to an empty string).

Error('My message of error', 'Type of error (optional)')

Show info of error

err = Error('Erro1') #With instance
print(err.info())   #Using method info() -> str

print(Error("Error 2", "Test").info())

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

custom_error-1.0.0.tar.gz (3.2 kB view hashes)

Uploaded Source

Built Distribution

custom_error-1.0.0-py3-none-any.whl (4.0 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