Function dontpanic::builder

source ยท
pub fn builder(api_key: impl Into<String>) -> Builder
Expand description

Main entrypoint to this library. Start here and call this first. Returns a Builder.

Example:

use anyhow::Result;

fn main() -> Result<()> {
    dontpanic::builder("<PROJECT_API_KEY>").build()?;
    panic!("This will send you an email, notification or Slack/Teams message");
}

A more complete example:

use anyhow::Result;

fn main() -> Result<()> {
    dontpanic::builder("<PROJECT_API_KEY>")
        .environment(if cfg!(debug_assertions) {
            "development"
        } else {
            "production"
        })
        .version(env!("CARGO_PKG_VERSION"))
        // or
        .version(env!("CI_COMMIT_SHORT_SHA")) // GitLab
        .build()?;

    panic!("This will send you an email, notification or Slack/Teams message");

    Ok(())
}