rust-lang / project-error-handling

Error handling project group
Apache License 2.0
268 stars 18 forks source link

The proposed format is not clear #46

Open pickfire opened 3 years ago

pickfire commented 3 years ago
thread 'main' panicked at 'config is always valid and exists', src/main.rs:4:33

Error:
    0: invalid config
    1: config file does not exist

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

As a user, I will likely be confused what is 0, 1. Is 0 nearer to exit or nearer to the source of error? Maybe rather than 0 we put source or sink? What about putting the source for each error to be clearer?

thread 'main' panicked at 'config is always valid and exists'

Error:
  src: invalid config, src/main.rs:4:33
    1: config file does not exist, src/main.rs:10:3

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

What about this? What about attaching more context to each path? Like instead of getting Path not found', it will sayXXX Path not found`?

yaahc commented 3 years ago

The current plan is to copy the output of anyhow, where the first error gets put on the same line, then there's a caused by section which only gets numbered if there are more than 1 source errors. As for the including the path, mara is working on that right now but we probably can't add it to the display impl without duplicating information massively across the ecosystem.

https://github.com/rust-lang/rust/pull/86826

pickfire commented 3 years ago

It's okay not to change the first line, but I think the 0, 1 thing is also hard to understand from someone not familiar with rust at first look. At least for me, I cannot differentiate between them easily, it's as bad as not putting in the extra numbers.