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

Render errors as-is if they already have ansi characters #506

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

ecooper
Copy link

@ecooper ecooper commented Dec 11, 2024

Problem

If a command throws an error message that has already been formatted for display, we clobber it and make it red. This means some errors, such as query syntax errors, lose the benefit of code highlighting.

Solution

Detect if a thrown error has been formatted for display already, and don't apply chalk.red if it has.

While I was here, I moved the error handling code into a single module for discoverability and eventually testing.

Result

Doesn't have ansi so it renders red:
Screenshot 2024-12-11 at 9 09 47 AM

Has ansi so we display as-is:
Screenshot 2024-12-11 at 9 10 19 AM

@ecooper ecooper requested a review from a team as a code owner December 11, 2024 17:12
Copy link
Contributor

@ptpaterson ptpaterson left a comment

Choose a reason for hiding this comment

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

awesome.

@ecooper ecooper merged commit 5a5c028 into v3 Dec 11, 2024
4 checks passed
@ecooper ecooper deleted the v3-no-strip-ansi branch December 11, 2024 18:03
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@wildemat wildemat mentioned this pull request Dec 18, 2024
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.

3 participants