diff --git a/skyflow/client/skyflow.py b/skyflow/client/skyflow.py index 6cba302..3dd6bf4 100644 --- a/skyflow/client/skyflow.py +++ b/skyflow/client/skyflow.py @@ -99,9 +99,8 @@ def remove_vault_config(self, vault_id): if vault_id in self.__vault_configs.keys(): self.__vault_configs.pop(vault_id) else: - log_error(SkyflowMessages.Error.INVALID_VAULT_ID.value, - SkyflowMessages.ErrorCodes.INVALID_INPUT.value, - logger = self.__logger) + raise SkyflowError(SkyflowMessages.Error.INVALID_VAULT_ID.value, + SkyflowMessages.ErrorCodes.INVALID_INPUT.value) def update_vault_config(self, config): validate_update_vault_config(self.__logger, config) @@ -141,9 +140,8 @@ def remove_connection_config(self, connection_id): if connection_id in self.__connection_configs.keys(): self.__connection_configs.pop(connection_id) else: - log_error(SkyflowMessages.Error.INVALID_CONNECTION_ID.value, - SkyflowMessages.ErrorCodes.INVALID_INPUT.value, - logger = self.__logger) + raise SkyflowError(SkyflowMessages.Error.INVALID_CONNECTION_ID.value, + SkyflowMessages.ErrorCodes.INVALID_INPUT.value) def update_connection_config(self, config): validate_update_connection_config(self.__logger, config) diff --git a/skyflow/error/_skyflow_error.py b/skyflow/error/_skyflow_error.py index 68c97fb..e23c013 100644 --- a/skyflow/error/_skyflow_error.py +++ b/skyflow/error/_skyflow_error.py @@ -1,3 +1,4 @@ +from skyflow.utils import SkyflowMessages from skyflow.utils.logger import log_error class SkyflowError(Exception): @@ -11,7 +12,7 @@ def __init__(self, self.message = message self.http_code = http_code self.grpc_code = grpc_code - self.http_status = http_status + self.http_status = http_status if http_status else SkyflowMessages.HttpStatus.BAD_REQUEST.value self.details = details self.request_id = request_id log_error(message, http_code, request_id, grpc_code, http_status, details) diff --git a/skyflow/service_account/_utils.py b/skyflow/service_account/_utils.py index 12ae41e..ce647a3 100644 --- a/skyflow/service_account/_utils.py +++ b/skyflow/service_account/_utils.py @@ -27,7 +27,7 @@ def is_expired(token, logger = None): except jwt.ExpiredSignatureError: return True except Exception: - log_error(SkyflowMessages.Error.JWT_DECODE_ERROR.value, invalid_input_error_code, logger = logger) + log_error_log(SkyflowMessages.Error.JWT_DECODE_ERROR.value, invalid_input_error_code) return True def generate_bearer_token(credentials_file_path, options = None, logger = None): diff --git a/skyflow/utils/_skyflow_messages.py b/skyflow/utils/_skyflow_messages.py index afbb07e..b12401f 100644 --- a/skyflow/utils/_skyflow_messages.py +++ b/skyflow/utils/_skyflow_messages.py @@ -284,6 +284,8 @@ class Interface(Enum): UPDATE = "UPDATE" DELETE = "DELETE" + class HttpStatus(Enum): + BAD_REQUEST = "Bad Request" class Warning(Enum): WARNING_MESSAGE = "WARNING MESSAGE" diff --git a/skyflow/utils/_utils.py b/skyflow/utils/_utils.py index fa17a70..c88a49b 100644 --- a/skyflow/utils/_utils.py +++ b/skyflow/utils/_utils.py @@ -341,7 +341,7 @@ def parse_invoke_connection_response(api_response: requests.Response): def log_and_reject_error(description, status_code, request_id, http_status=None, grpc_code=None, details=None, logger = None): - log_error(description, status_code, request_id, grpc_code, http_status, details, logger= logger) + raise SkyflowError(description, status_code, request_id, grpc_code, http_status, details) def handle_exception(error, logger): request_id = error.headers.get('x-request-id', 'unknown-request-id')