Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Make any exception human readable in easy way.

Project Description

prettyexc provides common exception representation to make human-readable exception in easy way.

You can install the package from PyPI

$ pip install prettyexc

Example

>>> from prettyexc import PrettyException

Put and get your arguments always

>>> class SimpleException(PrettyException):
...     pass
...
>>> e = SimpleException('any', 'plain', 'args', code=200, description='OK')
>>> print e
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)
>>> print e
MessageException(user_id=10): 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)
>>> print e
FormatException(user_id=10): User 10 has no permission.
>>> print e.message
User 10 has no permission.

Patch existing exceptions

>>> from prettyexc import patch
>>> from prettyexc import PrettyException, patch
>>> class AnException(Exception): pass
...
>>> patch(AnException, PrettyException)
>>> print AnException(status=404)
__main__.AnException(status=404)

Release History

History Node

0.6.0

History Node

0.5.2

History Node

0.5.1

History Node

0.5

History Node

0.4.2

History Node

0.4.1

History Node

0.4

History Node

0.3

This version
History Node

0.2

History Node

0.1

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
prettyexc-0.2.tar.gz
(4.9 kB) Copy SHA256 Hash SHA256
Source None Jan 11, 2013

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting