forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle Errors and Tables in Query (Azure#20658)
* initial commit * batch set * batch * tests + changes * more tests * lint * changelog * Apply suggestions from code review * comment * lint * querry * comments
- Loading branch information
1 parent
460a571
commit d518326
Showing
13 changed files
with
607 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
sdk/monitor/azure-monitor-query/azure/monitor/query/_exceptions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
from azure.core.exceptions import HttpResponseError | ||
|
||
class LogsQueryError(object): | ||
"""The code and message for an error. | ||
All required parameters must be populated in order to send to Azure. | ||
:ivar code: A machine readable error code. | ||
:vartype code: str | ||
:ivar message: A human readable error message. | ||
:vartype message: str | ||
:ivar details: error details. | ||
:vartype details: list[~monitor_query_client.models.ErrorDetail] | ||
:ivar innererror: Inner error details if they exist. | ||
:vartype innererror: ~azure.monitor.query.LogsQueryError | ||
:ivar additional_properties: Additional properties that can be provided on the error info | ||
object. | ||
:vartype additional_properties: object | ||
:ivar bool is_error: Boolean check for error item when iterating over list of | ||
results. Always True for an instance of a LogsQueryError. | ||
""" | ||
def __init__( | ||
self, | ||
**kwargs | ||
): | ||
self.code = kwargs.get('code', None) | ||
self.message = kwargs.get('message', None) | ||
self.details = kwargs.get('details', None) | ||
self.innererror = kwargs.get('innererror', None) | ||
self.additional_properties = kwargs.get('additional_properties', None) | ||
self.is_error = True | ||
|
||
@classmethod | ||
def _from_generated(cls, generated): | ||
if not generated: | ||
return None | ||
details = None | ||
if generated.details is not None: | ||
details = [d.serialize() for d in generated.details] | ||
return cls( | ||
code=generated.code, | ||
message=generated.message, | ||
innererror=cls._from_generated(generated.innererror) if generated.innererror else None, | ||
additional_properties=generated.additional_properties, | ||
details=details, | ||
) | ||
|
||
class QueryPartialErrorException(HttpResponseError): | ||
"""There is a partial failure in query operation. This is thrown for a single query operation | ||
when allow_partial_errors is set to False. | ||
:ivar code: A machine readable error code. | ||
:vartype code: str | ||
:ivar message: A human readable error message. | ||
:vartype message: str | ||
:ivar details: error details. | ||
:vartype details: list[~monitor_query_client.models.ErrorDetail] | ||
:ivar innererror: Inner error details if they exist. | ||
:vartype innererror: ~azure.monitor.query.LogsQueryError | ||
:ivar additional_properties: Additional properties that can be provided on the error info | ||
object. | ||
:vartype additional_properties: object | ||
""" | ||
|
||
def __init__(self, **kwargs): | ||
error = kwargs.pop('error', None) | ||
if error: | ||
self.code = error.code | ||
self.message = error.message | ||
self.details = [d.serialize() for d in error.details] if error.details else None | ||
self.innererror = LogsQueryError._from_generated(error.innererror) if error.innererror else None | ||
self.additional_properties = error.additional_properties | ||
super(QueryPartialErrorException, self).__init__(message=self.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.