From d3fb7c37566fdac9c1a9192aba974e5bff24e2db Mon Sep 17 00:00:00 2001 From: ag-ramachandran Date: Tue, 31 Mar 2026 13:53:45 +0530 Subject: [PATCH 1/2] PR: 628 --- azure-kusto-data/azure/kusto/data/exceptions.py | 7 ++++--- azure-kusto-data/tests/test_exceptions.py | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/azure-kusto-data/azure/kusto/data/exceptions.py b/azure-kusto-data/azure/kusto/data/exceptions.py index 5abcbd68..73763db4 100644 --- a/azure-kusto-data/azure/kusto/data/exceptions.py +++ b/azure-kusto-data/azure/kusto/data/exceptions.py @@ -120,9 +120,10 @@ class KustoApiError(KustoServiceError): Represents a standard API error from kusto. Use `get_api_error()` to retrieve more details. """ - def __init__(self, error_dict: dict, message: str = None, http_response: "Union[requests.Response, ClientResponse, None]" = None, kusto_response=None): + def __init__(self, error_dict: dict, message: Optional[str] = None, http_response: "Union[requests.Response, ClientResponse, None]" = None, kusto_response=None): self.error = OneApiError.from_dict(error_dict["error"]) - super().__init__(message or self.error.description, http_response, kusto_response) + service_error_message = message or self.error.description or "Unknown Kusto service error" + super().__init__(service_error_message, http_response, kusto_response) def get_api_error(self) -> OneApiError: return self.error @@ -211,4 +212,4 @@ class KustoClosedError(KustoError): """Raised when a client is closed.""" def __init__(self): - super().__init__("The client cannot be used because it was closed in the past.") + super().__init__("The client cannot be used because it was closed in the past.") \ No newline at end of file diff --git a/azure-kusto-data/tests/test_exceptions.py b/azure-kusto-data/tests/test_exceptions.py index 9840d9b7..7f28c842 100644 --- a/azure-kusto-data/tests/test_exceptions.py +++ b/azure-kusto-data/tests/test_exceptions.py @@ -1,4 +1,4 @@ -from azure.kusto.data.exceptions import OneApiError +from azure.kusto.data.exceptions import KustoApiError, OneApiError def test_parse_one_api_error(): @@ -101,3 +101,17 @@ def test_one_api_error_no_code_fail(): assert result.code == "FailedToParse" assert result.type == "FailedToParseOneApiError" assert not result.permanent + + +def test_kusto_api_error_without_message_no_exception_raised(): + error_dict = { + "error": { + "code": "400", + "message": "This is a sample error message." + } + } + + try: + KustoApiError(error_dict, http_response=None) + except Exception: + assert False, "Exception was raised" \ No newline at end of file From 04feebfd80570f8a509035fdfc09772853d75241 Mon Sep 17 00:00:00 2001 From: ag-ramachandran Date: Tue, 31 Mar 2026 14:21:26 +0530 Subject: [PATCH 2/2] *Reformat files --- azure-kusto-data/azure/kusto/data/exceptions.py | 6 ++++-- azure-kusto-data/tests/test_exceptions.py | 9 ++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/azure-kusto-data/azure/kusto/data/exceptions.py b/azure-kusto-data/azure/kusto/data/exceptions.py index 73763db4..3da752fe 100644 --- a/azure-kusto-data/azure/kusto/data/exceptions.py +++ b/azure-kusto-data/azure/kusto/data/exceptions.py @@ -120,7 +120,9 @@ class KustoApiError(KustoServiceError): Represents a standard API error from kusto. Use `get_api_error()` to retrieve more details. """ - def __init__(self, error_dict: dict, message: Optional[str] = None, http_response: "Union[requests.Response, ClientResponse, None]" = None, kusto_response=None): + def __init__( + self, error_dict: dict, message: Optional[str] = None, http_response: "Union[requests.Response, ClientResponse, None]" = None, kusto_response=None + ): self.error = OneApiError.from_dict(error_dict["error"]) service_error_message = message or self.error.description or "Unknown Kusto service error" super().__init__(service_error_message, http_response, kusto_response) @@ -212,4 +214,4 @@ class KustoClosedError(KustoError): """Raised when a client is closed.""" def __init__(self): - super().__init__("The client cannot be used because it was closed in the past.") \ No newline at end of file + super().__init__("The client cannot be used because it was closed in the past.") diff --git a/azure-kusto-data/tests/test_exceptions.py b/azure-kusto-data/tests/test_exceptions.py index 7f28c842..1e9cd1b3 100644 --- a/azure-kusto-data/tests/test_exceptions.py +++ b/azure-kusto-data/tests/test_exceptions.py @@ -104,14 +104,9 @@ def test_one_api_error_no_code_fail(): def test_kusto_api_error_without_message_no_exception_raised(): - error_dict = { - "error": { - "code": "400", - "message": "This is a sample error message." - } - } + error_dict = {"error": {"code": "400", "message": "This is a sample error message."}} try: KustoApiError(error_dict, http_response=None) except Exception: - assert False, "Exception was raised" \ No newline at end of file + assert False, "Exception was raised"