def json_error(code, message):
    """Returns a JSON-ified error object"""
    # Message can be an unserializable object.
    message = repr(message)
    return jsonify(dict(request=request.path, message=message)), code
Returns a JSON-ified error object