This file is indexed.

/usr/lib/python2.7/dist-packages/pecan/scaffolds/rest-api/+package+/errors.py is in python-pecan 0.6.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import json
import webob
from pecan.hooks import PecanHook


class JSONErrorHook(PecanHook):
    """
    A pecan hook that translates webob HTTP errors into a JSON format.
    """

    def on_error(self, state, exc):
        if isinstance(exc, webob.exc.HTTPError):
            return webob.Response(
                body=json.dumps({'reason': str(exc)}),
                status=exc.status,
                headerlist=exc.headerlist,
                content_type='application/json'
            )