Skip to main content

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.

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

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

msgfy-0.2.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

msgfy-0.2.1-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file msgfy-0.2.1.tar.gz.

File metadata

  • Download URL: msgfy-0.2.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for msgfy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 161024732591444cc05ca3982a010005932005ec861467dead49349447a91671
MD5 ef3c61804003f4356119f7d00c5932f9
BLAKE2b-256 510eb78151a63e8c5cab745e90ed7b4a741dba5439a8538636bf6a5da72bad23

See more details on using hashes here.

File details

Details for the file msgfy-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: msgfy-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for msgfy-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c6d12d963c3cec96359884fc598ae7f84f528de830bf55c9ccf3099a482ac63c
MD5 04350c3a45613080e213159b7290938a
BLAKE2b-256 35564563d668b18fe22fe4999347993e3120c72d5ce3c63e4b44e7fea770eccf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page