Skip to content

Tracking issue for improving our error handling and reporting strategy #236

@jieyouxu

Description

@jieyouxu

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 just eyre, 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 of ModInfoCtxt 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 abstract Reports which simplifies error handling alot.

Implementation history

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: error reporting and diagnosticsA-error-handlingArea: error handlingC-tracking-issueTracking issues keep track of a group of related issues or efforts

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions