diff --git a/src/core/error/mod.rs b/src/core/error/mod.rs index b704d701..4de4dbfb 100644 --- a/src/core/error/mod.rs +++ b/src/core/error/mod.rs @@ -8,17 +8,18 @@ use std::{ any::Any, borrow::Cow, convert::Infallible, - sync::{OnceLock, PoisonError}, + sync::{Mutex, PoisonError}, }; pub use self::{err::visit, log::*}; +use crate::utils::{assert_ref_unwind_safe, assert_send, assert_sync, assert_unwind_safe}; #[derive(thiserror::Error)] pub enum Error { #[error("PANIC!")] - PanicAny(OnceLock>), + PanicAny(Mutex>), #[error("PANIC! {0}")] - Panic(&'static str, OnceLock>), + Panic(&'static str, Mutex>), // std #[error(transparent)] @@ -141,6 +142,11 @@ pub enum Error { Err(Cow<'static, str>), } +static _IS_SEND: () = assert_send::(); +static _IS_SYNC: () = assert_sync::(); +static _IS_UNWIND_SAFE: () = assert_unwind_safe::(); +static _IS_REF_UNWIND_SAFE: () = assert_ref_unwind_safe::(); + impl Error { #[inline] #[must_use] diff --git a/src/core/error/panic.rs b/src/core/error/panic.rs index a77991cb..17af1f05 100644 --- a/src/core/error/panic.rs +++ b/src/core/error/panic.rs @@ -23,8 +23,8 @@ impl Error { pub fn into_panic(self) -> Box { match self { | Self::JoinError(e) => e.into_panic(), - | Self::Panic(_, mut e) | Self::PanicAny(mut e) => - e.take().expect("Error contained panic"), + | Self::Panic(_, e) | Self::PanicAny(e) => + e.into_inner().expect("Error contained panic"), | _ => Box::new(self), } }