Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve CLI error messages #3259

Merged
merged 4 commits into from
Jan 29, 2024
Merged

Improve CLI error messages #3259

merged 4 commits into from
Jan 29, 2024

Conversation

koesie10
Copy link
Member

This improves the CLI error messages by trying to parse the stderr if it matches a known exit code. This doesn't handle all cases, but it handles the most common cases. In case another error is returned, it will now simply print the stderr itself, rather than starting with ${description} failed with ${args}:. This can still be found in the extension logs, and is already printed when starting execution of the command in the extension logs as well.

Screenshot 2024-01-19 at 12 11 18

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

@koesie10 koesie10 marked this pull request as ready for review January 19, 2024 11:26
@koesie10 koesie10 requested a review from a team as a code owner January 19, 2024 11:26
@koesie10 koesie10 requested a review from a team January 19, 2024 11:27
@@ -62,6 +64,16 @@ export function registerCommandWithErrorHandling(
} else {
void showAndLogWarningMessage(logger, errorMessage.fullMessage);
}
} else if (e instanceof CliError) {
const fullMessage = `${e.commandDescription} failed with args:${EOL}${
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm not mistaken, this message will come out as:

SomeCommand failed with args:
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
stderr stderr stderr stderr stderr stderr stderr stderr
 arg1 arg2 arg3

Should the args come before the stderr?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right. I've updated this to be correct.

Copy link
Contributor

@robertbrignull robertbrignull left a comment

Choose a reason for hiding this comment

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

LGTM

@koesie10 koesie10 merged commit 978e48f into main Jan 29, 2024
32 checks passed
@koesie10 koesie10 deleted the koesie10/improve-error-message branch January 29, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants