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

tools: enable fancy miette errors in crowtty #345

Merged
merged 1 commit into from
Dec 27, 2024
Merged

Conversation

hawkw
Copy link
Contributor

@hawkw hawkw commented Dec 27, 2024

At some point (probably when crowtty was separated out into its own binary in #342), the miette dependency's "fancy" feature flag, which makes the debug print format for errors actually look nice and include cause chains, was eaten. This is a bummer, because having cause chains is important in order to understand the error message.

This commit re-enables the "fancy" feature flag for miette in crowtty's `Cargo.toml'.

Prior to this change, errors looked like this:

eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s
     Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace`
Error: Diagnostic { message: "failed to connect to /dev/ttyUSB1 (@ 115200)" }
NOTE: If you're looking for the fancy error reports, install miette with the `fancy` feature, or write your own and hook it up with miette::set_hook().

...which I think we can all agree is not that useful.

Now, the error looks like this:

eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.22s
     Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace`
Error:   × failed to connect to /dev/ttyUSB1 (@ 115200)
  ╰─▶ Device or resource busy

This actually explains what went wrong, which seems good to me.

At some point (probably when `crowtty` was separated out into its own
binary in #342), the `miette` dependency's `"fancy"` feature flag, which
makes the debug print format for errors actually look nice and include
cause chains, was eaten. This is a bummer, because having cause chains
is important in order to understand the error message.

This commit re-enables the `"fancy"` feature flag for `miette` in
`crowtty`'s `Cargo.toml'.

Prior to this change, errors looked like this:

```console
eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s
     Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace`
Error: Diagnostic { message: "failed to connect to /dev/ttyUSB1 (@ 115200)" }
NOTE: If you're looking for the fancy error reports, install miette with the `fancy` feature, or write your own and hook it up with miette::set_hook().

```

...which I think we can all agree is not that useful.

Now, the error looks like this:

```console
eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.22s
     Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace`
Error:   × failed to connect to /dev/ttyUSB1 (@ 115200)
  ╰─▶ Device or resource busy

```

This actually explains what went wrong, which seems good to me.
@hawkw hawkw enabled auto-merge December 27, 2024 17:54
@hawkw hawkw added this pull request to the merge queue Dec 27, 2024
Merged via the queue into main with commit 6536ed7 Dec 27, 2024
12 checks passed
@hawkw hawkw deleted the eliza/nice-crowtty-errors branch December 27, 2024 18:10
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.

1 participant