Skip to main content

Rise class for formatting thrown exception messages.

Project description

RaiseTool

The project contains small class for formatting thrown exception messages.

The message can be formatted with information about the class, method, and line number where the exception was thrown.

Public methods

Raise.message(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> str
Raise.attribute_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> AttributeError
Raise.connection_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> ConnectionError
Raise.key_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> KeyError
Raise.os_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> OSError
Raise.syntax_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> SyntaxError
Raise.type_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> TypeError
Raise.value_error(message:str, class_name:Optional[str],currentframe:Optional[FrameType])-> ValueError

Usage examples

import inspect
from raisetool.formatter import Raise


class Example:
    def __init__(self):
        print(f"1: {Raise.message('example message 1')}")
        print(
            f"2: {Raise.message('example message 2', self.__class__.__name__)}"
        )
        print(
            f"3: {Raise.message('example message 3', self.__class__.__name__, inspect.currentframe(), )}"
        )
        try:
            raise Raise.value_error(
                "example message 4",
                self.__class__.__name__,
                inspect.currentframe(),
            )
        except ValueError as ex:
            print(f"4: {ex.__class__.__name__}: {ex}")


if __name__ == "__main__":
    obj = Example()

Output:

1: example message 1
2: Example: example message 2
3: Example.__init__ [line:21]: example message 3
4: ValueError: Example.__init__ [line:24]: example message 4

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

raisetool-1.0.0.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

raisetool-1.0.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: raisetool-1.0.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.2 Linux/5.10.0-23-amd64

File hashes

Hashes for raisetool-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e96ad045f7472abe8247ad162d21ddfdb7308e39f121caf97dd9e5d35a532d52
MD5 9a5f16a889c9bca5810959ab3b71b6ed
BLAKE2b-256 dcfea3a6646b8bcd22f83f4d48d643a4fd54e0257d3e2702dc1bebc7a0966599

See more details on using hashes here.

File details

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

File metadata

  • Download URL: raisetool-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.2 Linux/5.10.0-23-amd64

File hashes

Hashes for raisetool-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c385feda9a150ce020a2d69251577d343e117a76c975c4e17b16fdd90bf327db
MD5 467a0fc853137f487e70f7674681631e
BLAKE2b-256 0034feef884dfc9a9ac595888c314ceda5ed313b992f3fd4af51ca6e68410204

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