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
Metadata
Release files for raisetool 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| raisetool-1.0.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| raisetool-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.6 kB
Release files / raisetool-1.0.0.tar.gz
| Download URL | raisetool-1.0.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e96ad045f7472abe8247ad162d21ddfdb7308e39f121caf97dd9e5d35a532d52
|
|
BLAKE2b-256 checksum How to use checksums |
dcfea3a6646b8bcd22f83f4d48d643a4fd54e0257d3e2702dc1bebc7a0966599
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.9.2 Linux/5.10.0-23-amd64
|
Release files / raisetool-1.0.0-py3-none-any.whl
| Download URL | raisetool-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c385feda9a150ce020a2d69251577d343e117a76c975c4e17b16fdd90bf327db
|
|
BLAKE2b-256 checksum How to use checksums |
0034feef884dfc9a9ac595888c314ceda5ed313b992f3fd4af51ca6e68410204
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.2 CPython/3.9.2 Linux/5.10.0-23-amd64
|