#[macro_use]
extern crate custom_derive;
#[macro_use]
extern crate newtype_derive;
pub use sentry;
custom_derive! {
#[derive(NewtypeFrom, NewtypeDeref, NewtypeDebug)]
pub struct Error(failure::Error);
}
impl<'r> rocket::response::Responder<'r> for Error {
fn respond_to(self, req: &rocket::Request) -> rocket::response::Result<'r> {
let mut event = sentry::integrations::failure::event_from_error(&self);
event.request = Some(sentry::protocol::Request {
url: format!(
"scheme://{}{}", req.headers().get_one("Host").unwrap_or("<no-host-header>"),
req.uri()
)
.parse()
.ok(),
method: Some(req.method().as_str().into()),
headers: req
.headers()
.iter()
.map(|h| (h.name().into(), h.value().into()))
.collect(),
..Default::default()
});
let uuid = sentry::capture_event(event); if uuid.is_nil() {
panic!("Could not send request event to Sentry. Make sure you are using matching sentry versions. Consider using sentry_rocket::sentry instead of sentry to make sure versions do match")
}
Err(rocket::http::Status::InternalServerError)
}
}