Azure / Azure/azure-cli

AzCLIError should take kwarg original_exception

Open
#16,348 2 comments 0 reactions 1 assignee Claimed by @houk-ms View on GitHub
Error Handling feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Is your feature request related to a problem? Please describe.**

When an exception is caught and wrapped by `AzCLIError`, the analysis of the root cause of the exception may not be correct, thus the recommendation can also be misleading.

For example, #15776 assumes `InvalidURL` is caused by invalid AAD endpoint in cloud registration, but the exception is actually caused by invalid proxy URL. This PR is later reverted by #15962.

In the current design, the original exception is discarded and it is very difficult to identify what the original issue is.

**Describe the solution you'd like**

`AzCLIError` should take optional kwarg `original_exception=None` and when any exception is wrapped/replaced by `AzCLIError`, `original_exception` should be set as the original exception so that `azure.cli.core.util.handle_exception` can log **callstack** and **error message** of `original_exception` to

- `--debug` log
- telemetry (if allowed)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.