Returns a JSON-ified error object

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