Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion doc/error_handling_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The newly designed error types are provided in [azure/cli/core/azclierror.py](ht
| | | -- FileOperationError
| | | -- ManualInterrupt
| | | -- ... More ...
| | | -- UnknownError # fallback of UserFault related errors
| | | -- UnclassifiedUserFault # fallback of UserFault related errors
Comment thread
houk-ms marked this conversation as resolved.
| | -- ClientError
| | | -- CLIInternalError
| | -- ServiceError
Expand Down
10 changes: 9 additions & 1 deletion src/azure-cli-core/azure/cli/core/azclierror.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ def send_telemetry(self):
telemetry.set_failure(self.error_msg)
if self.exception_trace:
telemetry.set_exception(self.exception_trace, '')


class UnknownError(AzCLIError):
""" Unclear errors, could not know who should be responsible for the errors.
DO NOT raise this error class in your codes. """
def send_telemetry(self):
super().send_telemetry()
telemetry.set_failure(self.error_msg)
# endregion


Expand Down Expand Up @@ -199,7 +207,7 @@ class ValidationError(UserFault):
pass


class UnknownError(UserFault):
class UnclassifiedUserFault(UserFault):
""" Fallback of the UserFault related error types.
Avoid using this class unless the error can not be classified into
the UserFault related specific error types.
Expand Down
4 changes: 2 additions & 2 deletions src/azure-cli-core/azure/cli/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def handle_exception(ex): # pylint: disable=too-many-locals, too-many-statement
az_error = azclierror.ValidationError(error_msg)

elif isinstance(ex, CLIError):
# TODO: Fine-grained analysis here for Unknown error
az_error = azclierror.UnknownError(error_msg)
# TODO: Fine-grained analysis here
az_error = azclierror.UnclassifiedUserFault(error_msg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why CLIError here is UserFault?

@houk-ms houk-ms Nov 12, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, CLIError will not show up here any more if it is deprecated.

Temporarily count the CLIError here as UserFaults for better Telemetry analysis. Because we could know almost all of the CLIErrors are UserFaults though may not 100%.

This is much better than counting CLIErrors as UnknownError. If so, a lot of userfaults are mis-categorized.


elif isinstance(ex, AzureError):
if extract_common_error_message(ex):
Expand Down