pub struct Error<K> { /* private fields */ }Expand description
Primary Error type from this crate.
Error contains a kind and an optional payload, which may be an OS Error Code, a Custom Message, or (with an allocator available) a custom Error object.
Implementations§
Source§impl<K> Error<K>
impl<K> Error<K>
Sourcepub const fn new_simple(kind: K) -> Self
pub const fn new_simple(kind: K) -> Self
Constructs a new error with a kind, but not payload
Sourcepub const fn new_with_message(kind: K, msg: &'static str) -> Self
pub const fn new_with_message(kind: K, msg: &'static str) -> Self
Constructs a new error with a kind and a custom message
Sourcepub fn new<E: Into<Box<dyn Error + Send + Sync + 'static>>>(
kind: K,
error: E,
) -> Self
pub fn new<E: Into<Box<dyn Error + Send + Sync + 'static>>>( kind: K, error: E, ) -> Self
Constructs a new error with a kind and a custom payload
Sourcepub fn raw_os_error(&self) -> Option<RawOsError>
pub fn raw_os_error(&self) -> Option<RawOsError>
Returns the raw os error if the error was constructed with one (via. Error::from_raw_os_error)
Sourcepub fn into_error(self) -> Option<Box<dyn Error + Send + Sync + 'static>>
pub fn into_error(self) -> Option<Box<dyn Error + Send + Sync + 'static>>
Converts self into an boxed error if a custom payload is present.
Error::into_error will return Some if constructed with a custom payload (Error::new, Error::other, or Error::uncategorized),
or if constructed with a custom message (Error::new_with_message, Error::other_with_message, or Error::uncategorized_with_message), and None otherwise.
Note that the latter case cannot be downcast.
Sourcepub fn into_inner(self) -> Option<Box<dyn Error + Send + Sync + 'static>>
pub fn into_inner(self) -> Option<Box<dyn Error + Send + Sync + 'static>>
Converts self into an boxed error if a custom payload is present.
Error::into_inner will return Some if constructed with a custom payload (Error::new, Error::other, or Error::uncategorized), and None otherwise.
Source§impl<K: ErrorKind> Error<K>
impl<K: ErrorKind> Error<K>
Sourcepub const fn other_simple() -> Self
pub const fn other_simple() -> Self
Constructs a new Error with no payload that indicates an other error.
Sourcepub const fn other_with_message(msg: &'static str) -> Self
pub const fn other_with_message(msg: &'static str) -> Self
Constructs a new Error with a custom message that indicates an other error.
Sourcepub fn other<E: Into<Box<dyn Error + Send + Sync + 'static>>>(error: E) -> Self
pub fn other<E: Into<Box<dyn Error + Send + Sync + 'static>>>(error: E) -> Self
Constructs a new Error with a custom payload that indicates an other error.
Sourcepub fn uncategorized_simple() -> Self
pub fn uncategorized_simple() -> Self
Constructs a new Error with no payload that indicates an uncategorized error.
Sourcepub fn uncategorized_with_message(msg: &'static str) -> Self
pub fn uncategorized_with_message(msg: &'static str) -> Self
Constructs a new Error with a custom message that indicates an uncategorized error.
Source§impl<K: FromRawOsError> Error<K>
impl<K: FromRawOsError> Error<K>
Sourcepub fn from_raw_os_error(error: RawOsError) -> Self
pub fn from_raw_os_error(error: RawOsError) -> Self
Constructs a new Error that contains an Error created from the OS