pub struct AnyError { /* private fields */ }
Expand description
AnyError is a serializable wrapper Error
.
It is can be used to convert other Error
into a serializable Error for transmission,
with most necessary info kept.
let e = AnyError::new(&fmt::Error{}).add_context(|| "example");
assert_eq!("core::fmt::Error: an error occurred when formatting an argument while: example", e.to_string());
Implementations
sourceimpl AnyError
impl AnyError
sourcepub fn new<E>(e: &E) -> Self where
E: Error + 'static,
pub fn new<E>(e: &E) -> Self where
E: Error + 'static,
Convert some Error
to AnyError.
- If there is a
source()
in the input error, it is also converted to AnyError, recursively. - A new backtrace will be built if there is not.
pub fn from_dyn(e: &(dyn Error + 'static), typ: Option<String>) -> Self
pub fn add_context<D: Display, F: FnOnce() -> D>(self, ctx: F) -> Self
pub fn get_type(&self) -> Option<&str>
pub fn backtrace(&self) -> Option<&str>
Trait Implementations
sourceimpl<'de> Deserialize<'de> for AnyError
impl<'de> Deserialize<'de> for AnyError
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Error for AnyError
impl Error for AnyError
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
sourceimpl PartialEq<AnyError> for AnyError
impl PartialEq<AnyError> for AnyError
impl Eq for AnyError
impl StructuralEq for AnyError
impl StructuralPartialEq for AnyError
Auto Trait Implementations
impl RefUnwindSafe for AnyError
impl Send for AnyError
impl Sync for AnyError
impl Unpin for AnyError
impl UnwindSafe for AnyError
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more