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 with_backtrace(self) -> 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
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
🔬 This is a nightly-only experimental API. (
backtrace)Returns a stack backtrace, if available, of where this error occurred. 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()
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 · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more