.. contents:: **msgfy**
:backlinks: top
:depth: 2
Summary
====================================
msgfy is a Python library for convert Exception instance to a human-readable error message.
.. image:: https://badge.fury.io/py/msgfy.svg
:target: https://badge.fury.io/py/msgfy
:alt: PyPI package version
.. image:: https://img.shields.io/pypi/pyversions/msgfy.svg
:target: https://pypi.org/project/msgfy
:alt: Supported Python versions
.. image:: https://github.com/thombashi/msgfy/actions/workflows/ci.yml/badge.svg
:target: https://github.com/thombashi/msgfy/actions/workflows/ci.yml
:alt: CI status of Linux/macOS/Windows
.. image:: https://coveralls.io/repos/github/thombashi/msgfy/badge.svg?branch=master
:target: https://coveralls.io/github/thombashi/msgfy?branch=master
:alt: Test coverage
.. image:: https://github.com/thombashi/msgfy/actions/workflows/github-code-scanning/codeql/badge.svg
:target: https://github.com/thombashi/msgfy/actions/workflows/github-code-scanning/codeql
:alt: CodeQL
Usage
====================================
Convert from Exception instance to an error message
------------------------------------------------------------------------
:Sample Code:
.. code:: python
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:
.. code:: python
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:
.. code:: python
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
-----------------
- `pytest <https://docs.pytest.org/en/latest/>`__
- `tox <https://testrun.org/tox/latest/>`__
Raw data
{
"_id": null,
"home_page": "https://github.com/thombashi/msgfy",
"name": "msgfy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "error",
"author": "Tsuyoshi Hombashi",
"author_email": "tsuyoshi.hombashi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/51/0e/b78151a63e8c5cab745e90ed7b4a741dba5439a8538636bf6a5da72bad23/msgfy-0.2.1.tar.gz",
"platform": null,
"description": ".. contents:: **msgfy**\n :backlinks: top\n :depth: 2\n\n\nSummary\n====================================\nmsgfy is a Python library for convert Exception instance to a human-readable error message.\n\n\n.. image:: https://badge.fury.io/py/msgfy.svg\n :target: https://badge.fury.io/py/msgfy\n :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/msgfy.svg\n :target: https://pypi.org/project/msgfy\n :alt: Supported Python versions\n\n.. image:: https://github.com/thombashi/msgfy/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/thombashi/msgfy/actions/workflows/ci.yml\n :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://coveralls.io/repos/github/thombashi/msgfy/badge.svg?branch=master\n :target: https://coveralls.io/github/thombashi/msgfy?branch=master\n :alt: Test coverage\n\n.. image:: https://github.com/thombashi/msgfy/actions/workflows/github-code-scanning/codeql/badge.svg\n :target: https://github.com/thombashi/msgfy/actions/workflows/github-code-scanning/codeql\n :alt: CodeQL\n\n\nUsage\n====================================\n\nConvert from Exception instance to an error message\n------------------------------------------------------------------------\n:Sample Code:\n .. code:: python\n\n import msgfy\n\n def error_message_example():\n try:\n raise ValueError(\"example message\")\n except ValueError as e:\n print(msgfy.to_error_message(e))\n\n error_message_example()\n\n:Output:\n ::\n\n ValueError: example error message\n\nSpecify message format\n------------------------------------\n:Sample Code:\n .. code:: python\n\n import msgfy\n\n def error_message_format_example():\n try:\n raise ValueError(\"example error message\")\n except ValueError as e:\n print(msgfy.to_error_message(e, \"{exception} {func_name}: {error_msg}\"))\n\n error_message_format_example()\n\n:Output:\n ::\n\n ValueError error_message_format_example: example error message\n\n\nConvert from Exception instance to a debug message\n------------------------------------------------------------------------\n:Sample Code:\n .. code:: python\n\n import msgfy\n\n def debug_message_example():\n try:\n raise ValueError(\"example debug message\")\n except ValueError as e:\n print(msgfy.to_debug_message(e))\n\n debug_message_example()\n\n:Output:\n ::\n\n ValueError <ipython-input-4-bdd569af197b>(5) debug_message_example: example debug message\n\n\nAvailable keywords for message formats\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n+---------------------+-----------------------------------------------+\n| Keyword | Replaced to |\n+=====================+===============================================+\n| ``\"{exception}\"`` | Exception class name |\n+---------------------+-----------------------------------------------+\n| ``\"{file_name}\"`` | File name that exception raised |\n+---------------------+-----------------------------------------------+\n| ``\"{line_no}\"`` | Line number where the exception raised |\n+---------------------+-----------------------------------------------+\n| ``\"{func_name}\"`` | Function name that exception raised |\n+---------------------+-----------------------------------------------+\n| ``\"{error_msg}\"`` | Message that passed to the exception instance |\n+---------------------+-----------------------------------------------+\n\n\nInstallation\n====================================\n\nInstall from PyPI\n------------------------------\n::\n\n pip install msgfy\n\nInstall from PPA (for Ubuntu)\n------------------------------\n::\n\n sudo add-apt-repository ppa:thombashi/ppa\n sudo apt update\n sudo apt install python3-msgfy\n\n\nDependencies\n====================================\nPython 3.7+\nNo external dependencies.\n\nTest dependencies\n-----------------\n- `pytest <https://docs.pytest.org/en/latest/>`__\n- `tox <https://testrun.org/tox/latest/>`__\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "msgfy is a Python library for convert Exception instance to a human-readable error message.",
"version": "0.2.1",
"project_urls": {
"Homepage": "https://github.com/thombashi/msgfy",
"Source": "https://github.com/thombashi/msgfy",
"Tracker": "https://github.com/thombashi/msgfy/issues"
},
"split_keywords": [
"error"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "35564563d668b18fe22fe4999347993e3120c72d5ce3c63e4b44e7fea770eccf",
"md5": "04350c3a45613080e213159b7290938a",
"sha256": "c6d12d963c3cec96359884fc598ae7f84f528de830bf55c9ccf3099a482ac63c"
},
"downloads": -1,
"filename": "msgfy-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "04350c3a45613080e213159b7290938a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 4360,
"upload_time": "2023-09-17T06:35:32",
"upload_time_iso_8601": "2023-09-17T06:35:32.580466Z",
"url": "https://files.pythonhosted.org/packages/35/56/4563d668b18fe22fe4999347993e3120c72d5ce3c63e4b44e7fea770eccf/msgfy-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "510eb78151a63e8c5cab745e90ed7b4a741dba5439a8538636bf6a5da72bad23",
"md5": "ef3c61804003f4356119f7d00c5932f9",
"sha256": "161024732591444cc05ca3982a010005932005ec861467dead49349447a91671"
},
"downloads": -1,
"filename": "msgfy-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "ef3c61804003f4356119f7d00c5932f9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 6102,
"upload_time": "2023-09-17T06:35:34",
"upload_time_iso_8601": "2023-09-17T06:35:34.507613Z",
"url": "https://files.pythonhosted.org/packages/51/0e/b78151a63e8c5cab745e90ed7b4a741dba5439a8538636bf6a5da72bad23/msgfy-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-09-17 06:35:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thombashi",
"github_project": "msgfy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "msgfy"
}