Actually re-establish and assert Syncness of Error. (98affbdeaf)
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -8,17 +8,18 @@ use std::{
|
|||||||
any::Any,
|
any::Any,
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
sync::{OnceLock, PoisonError},
|
sync::{Mutex, PoisonError},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use self::{err::visit, log::*};
|
pub use self::{err::visit, log::*};
|
||||||
|
use crate::utils::{assert_ref_unwind_safe, assert_send, assert_sync, assert_unwind_safe};
|
||||||
|
|
||||||
#[derive(thiserror::Error)]
|
#[derive(thiserror::Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("PANIC!")]
|
#[error("PANIC!")]
|
||||||
PanicAny(OnceLock<Box<dyn Any + Send>>),
|
PanicAny(Mutex<Box<dyn Any + Send>>),
|
||||||
#[error("PANIC! {0}")]
|
#[error("PANIC! {0}")]
|
||||||
Panic(&'static str, OnceLock<Box<dyn Any + Send + 'static>>),
|
Panic(&'static str, Mutex<Box<dyn Any + Send + 'static>>),
|
||||||
|
|
||||||
// std
|
// std
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
@@ -141,6 +142,11 @@ pub enum Error {
|
|||||||
Err(Cow<'static, str>),
|
Err(Cow<'static, str>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static _IS_SEND: () = assert_send::<Error>();
|
||||||
|
static _IS_SYNC: () = assert_sync::<Error>();
|
||||||
|
static _IS_UNWIND_SAFE: () = assert_unwind_safe::<Error>();
|
||||||
|
static _IS_REF_UNWIND_SAFE: () = assert_ref_unwind_safe::<Error>();
|
||||||
|
|
||||||
impl Error {
|
impl Error {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ impl Error {
|
|||||||
pub fn into_panic(self) -> Box<dyn Any + Send> {
|
pub fn into_panic(self) -> Box<dyn Any + Send> {
|
||||||
match self {
|
match self {
|
||||||
| Self::JoinError(e) => e.into_panic(),
|
| Self::JoinError(e) => e.into_panic(),
|
||||||
| Self::Panic(_, mut e) | Self::PanicAny(mut e) =>
|
| Self::Panic(_, e) | Self::PanicAny(e) =>
|
||||||
e.take().expect("Error contained panic"),
|
e.into_inner().expect("Error contained panic"),
|
||||||
| _ => Box::new(self),
|
| _ => Box::new(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user