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 details)

Uploaded Source

Built Distribution

custom_error-1.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file custom_error-1.0.0.tar.gz.

File metadata

  • Download URL: custom_error-1.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for custom_error-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6d52299647ba68c3e8baa484adb16c71533e38bef7f37d8d6387548a941f8a41
MD5 1aed92242172f9dfc02a96c9b79545d5
BLAKE2b-256 18d8d4089ad06860811cb26f54539d83772d15290b6bc4dbcf11e8f560f757ee

See more details on using hashes here.

File details

Details for the file custom_error-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for custom_error-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2539af765a9720183ddc4d4da4ab5561a40844c7c6900ce1ab4d481b272f81c1
MD5 1f9422099f8d33fb527affedc88315ef
BLAKE2b-256 a0034fe567c849d99c1be78ac390157aea012f83fb2baf499e0e3e60b23a1b37

See more details on using hashes here.

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