-
Notifications
You must be signed in to change notification settings - Fork 53
Description
Currently, our error handling is a bit all over the place (probably mostly my fault), which makes a lot of the code very verbose in terms of error handling, even though eventually at the user-level it does not necessarily aid them troubleshooting.
-
There are details from lower-levels that get propagated to higher-levels, but often such details are not important to the end user.
-
The propagation of errors across boundaries should ideally be presented more like an error stack, so that the user sees something akin to an error cause backtrace (semantically meaningful, not just locations into the source code). I'm thinking the user should be presented with something like
color_eyre
's example:color-eyre on hooked [$!] is 📦 v0.5.0 via 🦀 v1.44.0 ❯ RUST_LIB_BACKTRACE=1 cargo run --example usage Finished dev [unoptimized + debuginfo] target(s) in 0.04s Running `target/debug/examples/usage` Jul 05 19:16:02.853 INFO read_config:read_file{path="fake_file"}: Reading file Error: 0: Unable to read config 1: No such file or directory (os error 2)
-
The tricky part is when we want the root cause of a failure, such as which mod got yeeted from the cache, but this is also intermixed with other errors we don't care having exact information for.
Current proposed design
- A concept similar to
error_stack
, but we don't necessarily care about having the context switches. - We probably want to transition to
color_eyre
or justeyre
, since it has an error stack model and supports such error traces, and it supports adding arbitrary attachments and then downcasting in higher-level code -- which is perfect for our use case since we could attach some kind ofModInfoCtxt
to errors and then attempt to downcast them when we do need exact mod info. When we don't need exact mod info, leaf errors can be rolled up into abstractReport
s which simplifies error handling alot.