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

fix(graphical): render cause chains for inner errors #330

Merged
merged 1 commit into from
Jan 31, 2024

Conversation

TheLostLambda
Copy link
Contributor

Hi @zkat!

The default GraphicalReportHandler disables the printing of cause chains for any inner errors (errors related() to a source diagnostic) when it disables nested footer printing. This results in lost cause chain information when printing with the default report handler.

Before this PR:
image

After this PR:
image

This PR simply re-enables that cause-chain printing by removing the line where it was disabled. It looks like that line was added as part of the initial feature implementation in #170, but the current behavior of not printing the cause chains of inner errors (I found) surprising and it led me to scour my codebase trying to find where the source error was being lost.

If, however, retaining the current default behavior is preferred, I can implement a couple of methods on GraphicalReportHandler like .with_nested_cause_chains() and .without_nested_cause_chains() — just let me know!

Also more than happy to write some tests after I know if you're happy with changing this default behavior or if you'd prefer a configuration option was added!

Hope you are well!
Brooks

@TheLostLambda
Copy link
Contributor Author

TheLostLambda commented Jan 29, 2024

Whoops! Those tests didn't fail when I ran them locally, but I'll give then another look today! I'll get them passing!

EDIT: Forgot to enable "fancy" when running the tests... Duh!

@TheLostLambda
Copy link
Contributor Author

Turns out the line of code I deleted did have a reason to exist — go figure! I've added that back and turned back on the cause chains specifically for nested related errors. I've also added a test to capture the new behavior!

All tests are passing for me now (with cargo test --all --features fancy like is used in the CI)!

The default `GraphicalReportHandler` disables the printing of cause
chains for any inner errors (errors `related()` to a source diagnostic)
when it disables nested footer printing. This results in lost cause
chain information when printing with the default report handler.
@zkat zkat merged commit cb2ae2e into zkat:main Jan 31, 2024
11 checks passed
@TheLostLambda
Copy link
Contributor Author

Thanks @zkat !

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