Skip to content
This repository has been archived by the owner on Jul 13, 2018. It is now read-only.

sprockets/sprockets.mixins.json_error

Repository files navigation

sprockets.mixins.json_error

Handler mixin for writing JSON errors

Version Downloads Status Coverage License

Installation

sprockets.mixins.json_error is available on the Python Package Index and can be installed via pip or easy_install:

pip install sprockets.mixins.json_error

Documentation

https://sprocketsmixinsjson_error.readthedocs.org

Requirements

Example

This examples demonstrates how to use sprockets.mixins.json_error to format errors as JSON.

from sprockets import mixins.json_error
from tornado import web

class MyRequestHandler(json_error.JsonErrorMixin,
                       web.RequestHandler):

    def get(self, *args, **kwargs):
        raise web.HTTPError(404, log_message='My reason')

The response from the handler will automatically be formatted as:

{
    "message": "My reason",
    "type": "Not Found"
}

Version History

Available at https://sprocketsmixinsjson_error.readthedocs.org/en/latest/history.html