Skip to content

Multiple help? #227

Answered by zkat
aviramha asked this question in Q&A
Discussion options

You must be logged in to vote

If you're willing to do a wrapper, you could use something like this, if I understand what you're asking for:

struct WrapperErr(MyErrEnum);

impl trait miette::Diagnostic for WrapperErr {
  fn help<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
    let extra_help = "For more help please check out our documentation at https://github.com/example/example";
    if let Some(help) = self.0.help() {
      Some(Box::new(format!("{help}\n\n{extra_help}")))
    } else {
      Some(Box::new(extra_help))
    }
  }
  fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
    self.0.code()
  }
  fn severity(&self) -> Option<miette::Severity> {
    self.0.severity()
  }
  // ... etc, for all other p…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by zkat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants