Error

Struct Error 

Source
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>

Source

pub const fn new_simple(kind: K) -> Self

Constructs a new error with a kind, but not payload

Source

pub const fn new_with_message(kind: K, msg: &'static str) -> Self

Constructs a new error with a kind and a custom message

Source

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

Source

pub fn kind(&self) -> K
where K: Copy,

Returns the error Kind of the Error

Source

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)

Source

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.

Source

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>

Source

pub const fn other_simple() -> Self

Constructs a new Error with no payload that indicates an other error.

Source

pub const fn other_with_message(msg: &'static str) -> Self

Constructs a new Error with a custom message that indicates an other error.

Source

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.

Source

pub fn uncategorized_simple() -> Self

Constructs a new Error with no payload that indicates an uncategorized error.

Source

pub fn uncategorized_with_message(msg: &'static str) -> Self

Constructs a new Error with a custom message that indicates an uncategorized error.

Source

pub fn uncategorized<E: Into<Box<dyn Error + Send + Sync + 'static>>>( error: E, ) -> Self

Constructs a new Error with a custom payload that indicates an uncategorized error.

Source§

impl<K: FromRawOsError> Error<K>

Source

pub fn from_raw_os_error(error: RawOsError) -> Self

Constructs a new Error that contains an Error created from the OS

Trait Implementations§

Source§

impl<K: Debug> Debug for Error<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: ErrorKind> Display for Error<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K: ErrorKind> Error for Error<K>

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<K: IntoIoKind> From<Error<K>> for Error

Available on crate feature std only.
Source§

fn from(value: Error<K>) -> Self

Converts to this type from the input type.
Source§

impl<K: FromIoKind> From<Error> for Error<K>

Available on crate feature std only.
Source§

fn from(value: Error) -> Self

Converts to this type from the input type.
Source§

impl<K: FromIoKind> From<ErrorKind> for Error<K>

Available on crate feature std only.
Source§

fn from(kind: ErrorKind) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<K> Freeze for Error<K>
where K: Freeze,

§

impl<K> !RefUnwindSafe for Error<K>

§

impl<K> Send for Error<K>
where K: Send,

§

impl<K> Sync for Error<K>
where K: Sync,

§

impl<K> Unpin for Error<K>
where K: Unpin,

§

impl<K> !UnwindSafe for Error<K>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.