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§
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 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<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)>
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()