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) -> AnyErrorwhere
E: Error + 'static,
pub fn new<E>(e: &E) -> AnyErrorwhere
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>) -> AnyError
pub fn with_backtrace(self) -> AnyError
pub fn add_context<D, F>(self, ctx: F) -> AnyError
pub fn get_type(&self) -> Option<&str>
pub fn backtrace(&self) -> Option<&str>
Trait Implementations§
source§impl<T> AddContext<T, AnyError, AnyError> for Result<T, 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<AnyError, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<AnyError, <__D as Deserializer<'de>>::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)>
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()
source§impl From<AnyError> for NetworkError
impl From<AnyError> for NetworkError
source§impl From<AnyError> for Unreachable
impl From<AnyError> for Unreachable
source§impl PartialEq for AnyError
impl PartialEq for AnyError
source§impl Serialize for AnyError
impl Serialize for AnyError
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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