Skip to content

Implement a custom Error type for better error handling and presentation #17

@AliSoftware

Description

@AliSoftware

Migrate from using anyhow::Error in all places with .context(error message) to instead create a dedicated #[derive(Error)] enum Error type.

  • We should use the thiserrors crate to make it easy to associate custom error messages to each enum variant.
  • That enum could still contain an #[error(transparent)] Internal(#[from] anyhow::Error) variant to handle errors from external library calls that we don't handle specifically
  • fn main() could then check the error returned by match cli.command { … } and handle pretty-printing the error if it's one of ours (i.e. ensure we avoid the stacktrace-style scary output and only print a simple but clear unique error message, maybe in red) and fallback to regular stacktrace-like output for the Internal(anyhow::Error) variant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions