Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions azure-kusto-data/azure/kusto/data/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@
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

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Type annotation is missing for parameter "kusto_response" (reportMissingParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Type of parameter "kusto_response" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Variable not allowed in type expression (reportInvalidTypeForm)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Type of parameter "http_response" is partially unknown   Parameter type is "Response | Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Type of parameter "error_dict" is partially unknown   Parameter type is "dict[Unknown, Unknown]" (reportUnknownParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Type annotation is missing for parameter "kusto_response" (reportMissingParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Type of parameter "kusto_response" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Variable not allowed in type expression (reportInvalidTypeForm)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Type of parameter "http_response" is partially unknown   Parameter type is "Response | Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Type of parameter "error_dict" is partially unknown   Parameter type is "dict[Unknown, Unknown]" (reportUnknownParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Type annotation is missing for parameter "kusto_response" (reportMissingParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Type of parameter "kusto_response" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Variable not allowed in type expression (reportInvalidTypeForm)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Type of parameter "http_response" is partially unknown   Parameter type is "Response | Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Type of parameter "error_dict" is partially unknown   Parameter type is "dict[Unknown, Unknown]" (reportUnknownParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Type annotation is missing for parameter "kusto_response" (reportMissingParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Type of parameter "kusto_response" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Variable not allowed in type expression (reportInvalidTypeForm)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Type of parameter "http_response" is partially unknown   Parameter type is "Response | Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Type of parameter "error_dict" is partially unknown   Parameter type is "dict[Unknown, Unknown]" (reportUnknownParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Type annotation is missing for parameter "kusto_response" (reportMissingParameterType)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Type of parameter "kusto_response" is partially unknown   Parameter type is "Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Variable not allowed in type expression (reportInvalidTypeForm)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Type of parameter "http_response" is partially unknown   Parameter type is "Response | Unknown | None" (reportUnknownParameterType)

Check failure on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Expected type arguments for generic class "dict" (reportMissingTypeArgument)

Check warning on line 124 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Type of parameter "error_dict" is partially unknown   Parameter type is "dict[Unknown, Unknown]" (reportUnknownParameterType)
):
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)

Check warning on line 128 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Argument type is partially unknown   Argument corresponds to parameter "kusto_response" in function "__init__"   Argument type is "Unknown | None" (reportUnknownArgumentType)

Check warning on line 128 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Argument type is partially unknown   Argument corresponds to parameter "kusto_response" in function "__init__"   Argument type is "Unknown | None" (reportUnknownArgumentType)

Check warning on line 128 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Argument type is partially unknown   Argument corresponds to parameter "kusto_response" in function "__init__"   Argument type is "Unknown | None" (reportUnknownArgumentType)

Check warning on line 128 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Argument type is partially unknown   Argument corresponds to parameter "kusto_response" in function "__init__"   Argument type is "Unknown | None" (reportUnknownArgumentType)

Check warning on line 128 in azure-kusto-data/azure/kusto/data/exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Argument type is partially unknown   Argument corresponds to parameter "kusto_response" in function "__init__"   Argument type is "Unknown | None" (reportUnknownArgumentType)

def get_api_error(self) -> OneApiError:
return self.error
Expand Down
11 changes: 10 additions & 1 deletion azure-kusto-data/tests/test_exceptions.py
Original file line number Diff line number Diff line change
@@ -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():
Expand Down Expand Up @@ -101,3 +101,12 @@
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)

Check warning on line 110 in azure-kusto-data/tests/test_exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.11)

Result of call expression is of type "KustoApiError" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

Check warning on line 110 in azure-kusto-data/tests/test_exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.10)

Result of call expression is of type "KustoApiError" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

Check warning on line 110 in azure-kusto-data/tests/test_exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.9)

Result of call expression is of type "KustoApiError" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

Check warning on line 110 in azure-kusto-data/tests/test_exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.12)

Result of call expression is of type "KustoApiError" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)

Check warning on line 110 in azure-kusto-data/tests/test_exceptions.py

View workflow job for this annotation

GitHub Actions / build (3.13)

Result of call expression is of type "KustoApiError" and is not used; assign to variable "_" if this is intentional (reportUnusedCallResult)
except Exception:
assert False, "Exception was raised"
Loading