This commit is contained in:
parent
a4908fda80
commit
b1254d9029
|
@ -38,6 +38,5 @@ maze_generator = "2"
|
|||
once_cell = "1"
|
||||
pathfinding = "4"
|
||||
rand = "0.8"
|
||||
sentry = "0.29"
|
||||
serde = "1"
|
||||
shadowcast = "0.8"
|
24
src/error.rs
24
src/error.rs
|
@ -4,9 +4,6 @@ use std::{panic, thread};
|
|||
use backtrace::Backtrace;
|
||||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Resource)]
|
||||
struct Guard(sentry::ClientInitGuard);
|
||||
|
||||
pub fn error_handler(In(result): In<Result<(), Box<dyn Error>>>) {
|
||||
if let Err(e) = result {
|
||||
error!("{}", e);
|
||||
|
@ -47,29 +44,10 @@ fn init_panic_handler() {
|
|||
}));
|
||||
}
|
||||
|
||||
#[derive(Resource, Clone, Debug, Default)]
|
||||
pub struct ErrorConfig {
|
||||
pub sentry_dsn: Option<String>,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
pub struct ErrorPlugin;
|
||||
|
||||
impl Plugin for ErrorPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
fn build(&self, _app: &mut App) {
|
||||
init_panic_handler();
|
||||
if let Some(config) = app.world.get_resource::<ErrorConfig>() {
|
||||
if let Some(dsn) = &config.sentry_dsn {
|
||||
let release = config.version.clone().unwrap_or_default();
|
||||
let guard = sentry::init((
|
||||
dsn.as_str(),
|
||||
sentry::ClientOptions {
|
||||
release: Some(release.into()),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
app.insert_resource(Guard(guard));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user