msgfy is a Python library for convert Exception instance to a human-readable error message.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
msgfy
requirements
test
.coveragerc
.gitignore
.travis.yml
LICENSE
MANIFEST.in
Makefile
README.rst
appveyor.yml
pylama.ini
pyproject.toml
setup.cfg
setup.py
tox.ini

README.rst

msgfy

https://img.shields.io/travis/thombashi/msgfy/master.svg?label=Linux https://img.shields.io/appveyor/ci/thombashi/msgfy/master.svg?label=Windows https://coveralls.io/repos/github/thombashi/msgfy/badge.svg?branch=master

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

pip install msgfy

Dependencies

Python 2.7+ or 3.4+

Test dependencies