Example #1
0
def forbidden401(error):
    """
    Renders 401 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(message="Error 401: Unauthorized",
                              success=False,
                              data=error.description)), 401
def forbidden409(error):  # pylint: disable=unused-argument
    """
    Renders 409 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(message="Error 409: Conflict",
                              success=False,
                              data=error.description)), 409
Example #3
0
def forbidden400(error):
    """
    Renders 400 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(message="Error 400: Bad request",
                              success=False,
                              data=error.description)), 400
def not_found405(error):  # pylint: disable=unused-argument
    """
    Renders 405 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(message="Error 405: Method not allowed",
                              success=False,
                              data=None)), 405
def internal_server_error500(error):  # pylint: disable=unused-argument
    """
    Renders 500 response
    :returns: JSON
    :rtype: flask.Response
    """
    db.session.rollback()
    db.session.close()
    return jsonify(
        prepare_json_response(message="Error 500: Internal server error",
                              success=False,
                              data=None)), 405
def not_found411(error):  # pylint: disable=unused-argument
    """
    Renders 411 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(
            message=
            "Error 411: We don't have enough apartments/buildings similar to yours, we are working on solving that issue",
            success=False,
            data=None)), 411
def not_found410(error):  # pylint: disable=unused-argument
    """
    Renders 410 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(
            message=
            "Error 410: We don't have enough data in that zone, we will be there soon",
            success=False,
            data=None)), 410
def not_found404(error):  # pylint: disable=unused-argument
    """
    Renders 404 response
    :returns: JSON
    :rtype: flask.Response
    """
    if "message" in error.description:
        message = error.description["message"]
    else:
        message = "Error 404: Not found"
    return jsonify(
        prepare_json_response(message=message, success=False, data=None)), 404
Example #9
0
def not_found(error):
    """
    Renders 404 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(
            message="Error 404: Not found",
            success=False,
            data=None
        )
    ), 404
Example #10
0
def forbidden(error):
    """
    Renders 403 response
    :returns: JSON
    :rtype: flask.Response
    """
    return jsonify(
        prepare_json_response(
            message="Error 403: Forbidden",
            success=False,
            data=None
        )
    ), 403
Example #11
0
def internal_server_error(error):
    """
    Renders 500 response
    :returns: JSON
    :rtype: flask.Response
    """

    return jsonify(
        prepare_json_response(
            message="Error 500: Internal server error",
            success=False,
            data=None
        )
    ), 405