[−][src]Struct honeybadger::Honeybadger
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 theConfigBuilder
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]
self,
error: E,
context: Option<HashMap<&'req str, &'req str>>
) -> impl Future<Item = (), Error = Error> + '_ where
Error: From<E>,
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
error
- a struct that implements theFrom
trait for anotice::Error
.context
- OptionalHashMap
to pass to the Honeybadger context API
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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,