msgfy is a Python library for convert Exception instance to a human-readable error message.
Project description
Summary
msgfy is a Python library for convert Exception instance to a human-readable error message.
Usage
Convert from Exception instance to an error message
- Sample Code:
import msgfy def error_message_example(): try: raise ValueError("example message") except ValueError as e: print(msgfy.to_error_message(e)) error_message_example()
- Output:
ValueError: example error message
Specify message format
- Sample Code:
import msgfy def error_message_format_example(): try: raise ValueError("example error message") except ValueError as e: print(msgfy.to_error_message(e, "{exception} {func_name}: {error_msg}")) error_message_format_example()
- Output:
ValueError error_message_format_example: example error message
Convert from Exception instance to a debug message
- Sample Code:
import msgfy def debug_message_example(): try: raise ValueError("example debug message") except ValueError as e: print(msgfy.to_debug_message(e)) debug_message_example()
- Output:
ValueError <ipython-input-4-bdd569af197b>(5) debug_message_example: example debug message
Available keywords for message formats
Keyword |
Replaced to |
---|---|
"{exception}" |
Exception class name |
"{file_name}" |
File name that exception raised |
"{line_no}" |
Line number where the exception raised |
"{func_name}" |
Function name that exception raised |
"{error_msg}" |
Message that passed to the exception instance |
Installation
Install from PyPI
pip install msgfy
Install from PPA (for Ubuntu)
sudo add-apt-repository ppa:thombashi/ppa sudo apt update sudo apt install python3-msgfy
Dependencies
Python 2.7+ or 3.5+ No external dependencies.
Test dependencies
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
msgfy-0.0.7.tar.gz
(5.3 kB
view hashes)
Built Distribution
Close
Hashes for msgfy-0.0.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed14ef121857d3d7e660c9735e2eb8e17155e2e5dbc3ee5f380e531d40022fc2 |
|
MD5 | 4eb58c64711a2ea0e19a774b2e53b32d |
|
BLAKE2b-256 | afa12c98ebd88ee88d300a3eedd41e5b8c2781bf7d39ecf56abf91dd93721711 |