Integrate Sentry for crash logging.

This commit is contained in:
Nolan Darilek 2021-08-30 11:44:55 -05:00
parent 68e5143386
commit fae8b559cf
2 changed files with 13 additions and 1 deletions

View File

@ -33,4 +33,5 @@ mapgen = "0.5"
maze_generator = "1"
pathfinding = "2"
rand = "0.8"
sentry = "0.23"
shadowcast = "0.8"

View File

@ -44,10 +44,21 @@ fn init_panic_handler() {
}));
}
#[derive(Clone, Debug, Default)]
pub struct ErrorConfig {
pub sentry_dsn: Option<String>,
}
pub struct ErrorPlugin;
impl Plugin for ErrorPlugin {
fn build(&self, _: &mut AppBuilder) {
fn build(&self, app: &mut AppBuilder) {
init_panic_handler();
if let Some(config) = app.world().get_resource::<ErrorConfig>() {
if let Some(dsn) = &config.sentry_dsn {
let guard = sentry::init(dsn.clone());
app.insert_resource(guard);
}
}
}
}