Closed rufuspollock closed 12 years ago
Borrow from excellent work of pudo in the datahub (see web.py):
@app.errorhandler(401) @app.errorhandler(403) @app.errorhandler(404) @app.errorhandler(410) @app.errorhandler(500) def handle_exceptions(exc): """ Re-format exceptions to JSON if accept requires that. """ format = response_format(app, request) if format == 'json': body = {'status': exc.code, 'name': exc.name, 'description': exc.get_description(request.environ)} return jsonify(body, status=exc.code, headers=exc.get_headers(request.environ)) return exc
This was for python so no longer valid.
Borrow from excellent work of pudo in the datahub (see web.py):