Fix panic context

This commit is contained in:
Aleksey Kladov 2020-10-23 15:18:33 +02:00
parent 31db677a94
commit 1a74f25f90
2 changed files with 5 additions and 5 deletions

View file

@ -34,7 +34,7 @@ impl<'a> RequestDispatcher<'a> {
}; };
let world = panic::AssertUnwindSafe(&mut *self.global_state); let world = panic::AssertUnwindSafe(&mut *self.global_state);
let response = panic::catch_unwind(move || { let response = panic::catch_unwind(move || {
stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); let _pctx = stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params));
let result = f(world.0, params); let result = f(world.0, params);
result_to_response::<R>(id, result) result_to_response::<R>(id, result)
}) })
@ -64,7 +64,7 @@ impl<'a> RequestDispatcher<'a> {
let world = self.global_state.snapshot(); let world = self.global_state.snapshot();
move || { move || {
let _ctx = let _pctx =
stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params)); stdx::panic_context::enter(format!("request: {} {:#?}", R::METHOD, params));
let result = f(world, params); let result = f(world, params);
Task::Response(result_to_response::<R>(id, result)) Task::Response(result_to_response::<R>(id, result))
@ -160,7 +160,7 @@ impl<'a> NotificationDispatcher<'a> {
return Ok(self); return Ok(self);
} }
}; };
stdx::panic_context::enter(format!("notification: {}", N::METHOD)); let _pctx = stdx::panic_context::enter(format!("notification: {}", N::METHOD));
f(self.global_state, params)?; f(self.global_state, params)?;
Ok(self) Ok(self)
} }

View file

@ -4,7 +4,7 @@
use std::{cell::RefCell, panic, sync::Once}; use std::{cell::RefCell, panic, sync::Once};
pub fn enter(context: String) -> impl Drop { pub fn enter(context: String) -> PanicContext {
static ONCE: Once = Once::new(); static ONCE: Once = Once::new();
ONCE.call_once(PanicContext::init); ONCE.call_once(PanicContext::init);
@ -13,7 +13,7 @@ pub fn enter(context: String) -> impl Drop {
} }
#[must_use] #[must_use]
struct PanicContext { pub struct PanicContext {
_priv: (), _priv: (),
} }