Azure / Azure/azure-cli

Remove redundant error code and error message from Cli error output

Open
#22,981 5 comments 0 reactions 1 assignee Claimed by @lmazuel View on GitHub
Communication Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

**Related command**

When running a command fails, the CLI prints redundant error information:
First line is always the summary which contains the error code and the error message.
Consequent lines contain the error code, error message, error details and and inner errors / inner exceptions if any.
The error code and error message always appear twice.

**Describe the solution you'd like**

Remove error code from the one line summary and remove the error message from the detailed message as they are both redundant. If the error has any details or inner errors, they will be printed together with the error code in the detailed message.

**Describe alternatives you've considered**

1. Dropping the detailed message completely and keeping the one line summary (which is error-code plus error message). While this is enough in most use cases, it could be masking important information and leaves no way for the caller to get the error details or inner exceptions if any.

2. Dropping the summary and always return the detailed error. Downside is, we loose the nice one-line summary, which is all that is needed to debug the issues most of the times.

3. Output the detailed message only when user is specifically asking for it with something like `--verbose/-v`.

**Additional context**

Please see [_error_format.py](https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/aaz/_error_format.py).

And this is current error printed:

![image](https://user-images.githubusercontent.com/105318860/175246283-ed54722b-8ab1-4c00-a749-6baa2c83da4b.png)

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.