from requests import Response


class ErrorResponseUtil(object):

    @staticmethod
    def get_error_response(response, message_not_found="$NOT_FOUND"):
        # type: (Response, str) -> str

        if response is not None:
            if response.status_code in [400, 403, 404]:
                return message_not_found
            if response.status_code == 503:
                return "$CONNECTION_NOT_FOUND"
            if response.status_code == 412:
                return "$INVALID_BOH_CONFIGURATION"
            if response.reason is not None:
                return response.reason

        return "$UNKNOWN_ERROR"
