prettyexc provides common exception representation to make human-readable exception in easy way.
You can install the package from PyPI
$ pip install prettyexc
Example
- Prelude::
>>> from prettyexc import PrettyException
- Put and get your arguments always::
>>> class SimpleException(PrettyException): ... pass ... >>> e = SimpleException('any', 'plain', 'args', code=200, description='OK') >>> raise e Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.SimpleException: "any","plain","args",code=200,description="OK" SimpleException("any","plain","args",code=200,description="OK") >>> print [e, e] [<SimpleException("any","plain","args",code=200,description="OK")>, <SimpleException("any","plain","args",code=200,description="OK")>]- Set default message::
>>> class MessageException(PrettyException): ... message = u'You should select a user' ... >>> e = MessageException(user_id=10) >>> raise e Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.MessageException: You should select a user >>> print [e, e] [<MessageException(user_id=10)>, <MessageException(user_id=10)>]
- Set message formatter::
>>> class FormatException(PrettyException): ... message_format = u'User {user_id} has no permission.' ... >>> e = FormatException(user_id=10) >>> raise e Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.FormatException: User 10 has no permission. >>> print e.message User 10 has no permission.- Patch existing exceptions::
>>> from prettyexc import patch >>> class AnException(Exception): pass ... >>> patch(AnException, PrettyException) >>> raise AnException(status=404) Traceback (most recent call last): File "<stdin>", line 1, in <module> __main__.AnException: status=404
Metadata
Release files for prettyexc 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| prettyexc-0.6.0.tar.gz | 5.4 kB | Without provenance | Details for prettyexc-0.6.0.tar.gz |
Release files / prettyexc-0.6.0.tar.gz
| Download URL | prettyexc-0.6.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4187ad20fdf6f61188cf9ef5c7822342f55a6475afdbc96e4dcee432d6dbbdec
|
|
BLAKE2b-256 checksum How to use checksums |
326a3334c590ceffb591546140b403a9ec207f69690229a15f83db5f7eb651f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for prettyexc 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.