[][src]Struct honeybadger::Honeybadger

pub struct Honeybadger { /* fields omitted */ }

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

Methods

impl Honeybadger[src]

pub fn new(config: Config) -> Result<Self>[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());

pub fn notify<'req, E: Into<Error>>(
    self,
    error: E,
    context: Option<HashMap<&'req str, &'req str>>
) -> impl Future<Item = (), Error = Error> + '_ where
    Error: From<E>, 
[src]

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

Examples

With chained_error::Error

#[macro_use] extern crate error_chain;
error_chain! {
  errors {
    MyCustomError
  }
}

let error : Result<()> = Err(ErrorKind::MyCustomError.into());

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

rt.block_on(future);

With failure::Error

#[macro_use] extern crate failure;
#[derive(Fail, Debug)]
#[fail(display = "Failure error")]
struct MyCustomError;

let error: Result<(), failure::Error> = Err(MyCustomError {}.into());

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

rt.block_on(future);

With Box<std::error::Error>.

Note that std::error::Error does not implement Sync, and it's not possible to use the error type across future combinators, so it's recommended to convert into a Box<std::error::Error> in the same closure as the Honeybadger API call.


let error: Result<(), Box<std::error::Error>> = Err(
  std::io::Error::new(
    std::io::ErrorKind::Other, "std Error"
  ).into()
);

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

rt.block_on(future);

Auto Trait Implementations

impl Send for Honeybadger

impl Sync for Honeybadger

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T