Struct honeybadger::Honeybadger[][src]

pub struct Honeybadger { /* fields omitted */ }

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

Methods

impl Honeybadger
[src]

Constructs a Honeybadger instance, which may be used to send API notify requests.

Arguments

  • config - Config instance, which is built using the ConfigBuilder

Example

let config = ConfigBuilder::new(api_token).build();

assert_eq!(true, Honeybadger::new(config).is_ok());

Prepare a payload for the notify request.

Requires the use of the error_chain crate.

Use the into_payload method for generic error types.


Arguments

Example

error_chain! {
  errors {
    MyCustomError
  }
}

let error : Result<()> = Err(ErrorKind::MyCustomError.into());
honeybadger.create_payload(&error.unwrap_err(), None);

Generic method to prepare a payload for the notify request.

Useful alternative if error_chain crate is not being used for the error being sent to Honeybadger. Requires a From implementation for a notice::Error.

This module provides an implementation for the failure::Error type, so into_payload is useable out-of-the-box for non-custom types from the failure crate.


Arguments

Example

fn parse_number(num: &str) -> Result<i32, failure::Error> {
  let r = num.parse::<i32>()?;
  Ok(r)
}

honeybadger.into_payload(parse_number("foobar").unwrap_err(), None);

Implementing the Fail trait

If you are deriving Fail or have a custom struct that implements Fail, in order to enable this API, implement the From trait for the particular struct to convert it to a notice::Error for use as a honeybadger payload.


Trigger the notify request using an async HTTPS request.

Requires an initialized Tokio Runtime, and returns a Future that must be resolved using the Tokio framework orchestration methods.

Arguments

  • request - Request instance constructed with create_payload

Example

let mut rt = current_thread::Runtime::new().unwrap();
let payload = honeybadger.create_payload(&error.unwrap_err(), None).unwrap();
let future = honeybadger.notify(payload);

// note: blocks the current thread!
rt.block_on(future);

Auto Trait Implementations

impl Send for Honeybadger

impl Sync for Honeybadger