Skip to content

feat: use more compact default Debug format#52

Open
kanru wants to merge 1 commit intofast:mainfrom
kanru-contrib:compact-tree-debug
Open

feat: use more compact default Debug format#52
kanru wants to merge 1 commit intofast:mainfrom
kanru-contrib:compact-tree-debug

Conversation

@kanru
Copy link
Copy Markdown

@kanru kanru commented Apr 21, 2026

Removes the empty line between errors and use box-drawing characters for compact rendering.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates exn’s default Debug formatting to render error trees more compactly by removing the extra blank separator line and switching to box-drawing characters.

Changes:

  • Update write_exn to print child frames using ├── / └── connectors and indentation.
  • Refresh Insta snapshots to match the new compact Debug output across linear and tree-shaped error graphs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
exn/src/debug.rs Changes the Debug tree rendering to use box-drawing connectors and removes the extra separator line.
exn/tests/snapshots/main__tree_error.snap Updates expected tree-shaped debug output to new connector style.
exn/tests/snapshots/main__linear_error.snap Updates expected linear-chain debug output to new connector style.
exn/tests/snapshots/main__result_ext.snap Updates expected debug output for ResultExt case.
exn/tests/snapshots/main__new_with_source.snap Updates expected debug output for Exn::new with source.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread exn/src/debug.rs
Comment on lines 49 to +54
for (i, child) in children.iter().enumerate() {
write!(f, "\n{}|", prefix)?;
write!(f, "\n{}|-> ", prefix)?;
if i != children_len - 1 {
write!(f, "\n{}├── ", prefix)?;
} else {
write!(f, "\n{}└── ", prefix)?;
}
Comment thread exn/src/debug.rs Outdated
Comment on lines +50 to +54
if i != children_len - 1 {
write!(f, "\n{}├── ", prefix)?;
} else {
write!(f, "\n{}└── ", prefix)?;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This new symbol appears to be a general UTF-8 character rather than standard ASCII. We have previously encountered issues where this displays as garbled text in environments that do not support UTF-8.

Because of this, we prefer to keep the default format using simple ASCII. We want to ensure the default setting remains as simple as possible to maintain compatibility across more scenarios.

If you require a more sophisticated display, we have an example available that demonstrates how to create a customized display - https://github.com/fast/exn/blob/534fda198c61ab4021fccabe4778fa6c87f6470c/examples/src/custom-layout.rs

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the quick review!

I'm OK with plain ASCII characters. My real issue is with the blank lines. I'd like to use all the limited screen space to render as much as errors clearly if possible. I wonder whether there is a middle ground 🤔

Copy link
Copy Markdown
Contributor

@tisonkun tisonkun Apr 21, 2026

Choose a reason for hiding this comment

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

You can try changing the characters to the ASCII version and updating the snapshot to see the result.

Currently, there are some failing test cases in the CI. You can take a look and see how to fix them; I suspect it might be related to examples.

@kanru kanru force-pushed the compact-tree-debug branch from 95f1504 to 2065b51 Compare April 21, 2026 22:38
@kanru kanru force-pushed the compact-tree-debug branch from 2065b51 to 2f7daec Compare April 21, 2026 22:52
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