diff --git a/src/lib.rs b/src/lib.rs index 10550d1..5ffcfc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,6 +62,7 @@ pub struct Metadata { authors: Option>, homepage: Option>, support: Option>, + report: Option>, } impl Metadata { @@ -73,6 +74,7 @@ impl Metadata { authors: None, homepage: None, support: None, + report: None, } } @@ -102,6 +104,15 @@ impl Metadata { } self } + + /// The report information + pub fn report(mut self, value: impl Into>) -> Self { + let value = value.into(); + if !value.is_empty() { + self.report = value.into(); + } + self + } } /// Initialize [`Metadata`] @@ -133,6 +144,7 @@ macro_rules! metadata { /// setup_panic!(Metadata::new(env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION")) /// .authors("My Company Support ") /// .homepage("support.mycompany.com") +/// .report("Please attach this file to your support request.") /// .support("- Open a support request by email to support@mycompany.com") /// ); /// ``` @@ -224,6 +236,7 @@ fn write_msg>( authors, homepage, support, + report, .. } = meta; @@ -235,14 +248,16 @@ fn write_msg>( )?; writeln!( buffer, - "We have generated a report file at \"{}\". Submit an \ - issue or email with the subject of \"{} Crash Report\" and include the \ - report as an attachment.\n", + "We have generated a report file at \"{}\". {}\n", match file_path { Some(fp) => format!("{}", fp.as_ref().display()), None => "".to_owned(), }, - name + if let Some(report) = report { + report.to_string() + } else { + format!("Submit an issue or email with the subject of \"{} Crash Report\" and include the report as an attachment.", name) + } )?; if let Some(homepage) = homepage { diff --git a/tests/custom-panic/src/main.rs b/tests/custom-panic/src/main.rs index ff71b86..9ecc1ba 100644 --- a/tests/custom-panic/src/main.rs +++ b/tests/custom-panic/src/main.rs @@ -5,6 +5,7 @@ fn main() { setup_panic!(metadata!() .authors("My Company Support