1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#[allow(unused_imports)]
use sentry::{
integrations::backtrace::current_stacktrace,
protocol::{Event, Exception, Mechanism},
};
pub fn panic_event_from<T>(msg: T) -> Event<'static>
where
T: ToString,
{
let exception = Exception {
ty: "panic".into(),
mechanism: Some(Mechanism {
ty: "panic".into(),
handled: Some(false),
..Default::default()
}),
value: Some(msg.to_string()),
..Default::default()
};
Event {
exception: vec![exception].into(),
level: sentry::Level::Fatal,
..Default::default()
}
}