[][src]Crate honeybadger

An unofficial Honeybadger Rust client

Description

Honeybadger is a service that receives, stores and alerts on application errors and outages. This library is a community-provided client for the Honeybadger Exceptions API.

Underneath, the client uses a Tokio-based version of Hyper. Familiarity with Tokio-based systems is recommended.

Error library compatibility

The library provides convenience conversion traits and methods to generate a Honeybadger payload for use in the Honeybadger::notify API endpoint, based on popular error Rust libraries.

  • a From conversion trait enables use of a failure::Error, if using the failure crate.

  • the notice::Error::new convenience method creates a notice::Error Honeybadger payload, if using the error_chain crate.

  • alternatively, a From trait allows use of a simple Box<std::error::Error>, if using errors from the Rust standard library.

Backtraces are only supported in the ErrorChain and Failure crates.

Example

Assuming the project is setup to use ErrorChain, the following example will execute code in do_work, send a honeybadger exception if it fails, and subsequently end the program.

use tokio::prelude::*;
use tokio::prelude::future::result;
use tokio::runtime::run;

fn do_work() -> Result<()> {

  // write code ...

  Ok(())
}

// let api_token = "...";
let config = ConfigBuilder::new(api_token).build();
let mut hb = Honeybadger::new(config).unwrap();

let work = result(do_work())
  .or_else(move |e| hb.notify(honeybadger::notice::Error::new(&e), None))
  .map_err(|e| println!("error = {:?}", e));

run(work);

Please check the examples folder for further alternatives.

Modules

errors

Errors used by this package and chained from upstream libraries

notice

Data structures for marshaling to honeybadger's API

Structs

ConfigBuilder

Configuration builder struct, used for building a Config instance

Honeybadger

Instance containing the client connection and user configuration for this crate.