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 err = fmt::Error {};
let e = AnyError::new(&err).add_context(|| "running test");
assert_eq!(
"core::fmt::Error: an error occurred when formatting an argument while: running test",
e.to_string()
);Implementations§
Source§impl AnyError
impl AnyError
Sourcepub fn new<E>(e: &E) -> Selfwhere
E: Error + 'static,
pub fn new<E>(e: &E) -> Selfwhere
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 backtrace(&self) -> Option<&str>
Trait Implementations§
Source§impl<T> AddContext<T, AnyError, AnyError> for Result<T, AnyError>
When adding context info, convert an AnyError to another AnyError.
impl<T> AddContext<T, AnyError, AnyError> for Result<T, AnyError>
When adding context info, convert an AnyError to another AnyError.
Source§impl<'de> Deserialize<'de> for AnyError
impl<'de> Deserialize<'de> for AnyError
Source§fn 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
Source§impl Error for AnyError
impl Error for AnyError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl Eq for AnyError
impl StructuralPartialEq for AnyError
Auto Trait Implementations§
impl Freeze for AnyError
impl RefUnwindSafe for AnyError
impl Send for AnyError
impl Sync for AnyError
impl Unpin for AnyError
impl UnwindSafe for AnyError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more