Struct honeybadger::Honeybadger [−][src]
pub struct Honeybadger { /* fields omitted */ }
Instance containing the client connection and user configuration for this crate.
Methods
impl Honeybadger
[src]
impl Honeybadger
pub fn new(config: Config) -> Result<Self>
[src]
pub fn new(config: Config) -> Result<Self>
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 create_payload<'req, E>(
&mut self,
error: &E,
context: Option<HashMap<&'req str, &'req str>>
) -> Result<Request<Body>> where
E: ChainedError,
[src]
pub fn create_payload<'req, E>(
&mut self,
error: &E,
context: Option<HashMap<&'req str, &'req str>>
) -> Result<Request<Body>> where
E: ChainedError,
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
error
-ChainedError
reference compatible with an error_chain cratecontext
- OptionalHashMap
to pass to the Honeybadger context API
Example
error_chain! { errors { MyCustomError } } let error : Result<()> = Err(ErrorKind::MyCustomError.into()); honeybadger.create_payload(&error.unwrap_err(), None);
pub fn into_payload<'req, E: Into<Error>>(
&mut self,
error: E,
context: Option<HashMap<&'req str, &'req str>>
) -> Result<Request<Body>> where
Error: From<E>,
[src]
pub fn into_payload<'req, E: Into<Error>>(
&mut self,
error: E,
context: Option<HashMap<&'req str, &'req str>>
) -> Result<Request<Body>> where
Error: From<E>,
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
error
- a concrete value that implements theFrom
trait for anotice::Error
.context
- OptionalHashMap
to pass to the Honeybadger context API
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.
pub fn notify<'req>(
&mut self,
request: Request<Body>
) -> impl Future<Item = (), Error = Error>
[src]
pub fn notify<'req>(
&mut self,
request: Request<Body>
) -> impl Future<Item = (), Error = Error>
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 withcreate_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 Send for Honeybadger
impl Sync for Honeybadger
impl Sync for Honeybadger