Skip to main content

Summary

msgfy is a Python library for convert Exception instance to a human-readable error message.

PyPI package version Supported Python versions CI status of Linux/macOS/Windows Test coverage CodeQL

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 3.7+ No external dependencies.

Test dependencies

Release files for msgfy 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msgfy 0.2.1
File Size Uploaded
msgfy-0.2.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for msgfy 0.2.1
File Interpreter ABI Platform
msgfy-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / msgfy-0.2.1.tar.gz

Download URL msgfy-0.2.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
161024732591444cc05ca3982a010005932005ec861467dead49349447a91671
BLAKE2b-256 checksum
How to use checksums
510eb78151a63e8c5cab745e90ed7b4a741dba5439a8538636bf6a5da72bad23
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / msgfy-0.2.1-py3-none-any.whl

Download URL msgfy-0.2.1-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6d12d963c3cec96359884fc598ae7f84f528de830bf55c9ccf3099a482ac63c
BLAKE2b-256 checksum
How to use checksums
35564563d668b18fe22fe4999347993e3120c72d5ce3c63e4b44e7fea770eccf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page