pub enum Error<D: Domain> {
Domain(Box<D>),
Bug(Bug),
}
Expand description
Use Result<T, explicit_error::Error>
as the return type of any binary crate
faillible function returning errors.
The Error::Bug variant is for errors that should not happen but cannot panic.
The Error::Domain variant is for domain errors that provide feedbacks to the user.
For library or functions that require the caller to pattern match on the returned error, a dedicated type is prefered.
Variants§
Implementations§
Source§impl<D> Error<D>where
D: Domain,
impl<D> Error<D>where
D: Domain,
Sourcepub fn is_domain(&self) -> bool
pub fn is_domain(&self) -> bool
Return true if it’s a Error::Domain variant
Sourcepub fn is_bug(&self) -> bool
pub fn is_bug(&self) -> bool
Return true if it’s a Error::Bug variant
Sourcepub fn unwrap(self) -> D
pub fn unwrap(self) -> D
Unwrap the Error::Domain variant, panic otherwise
Sourcepub fn unwrap_bug(self) -> Bug
pub fn unwrap_bug(self) -> Bug
Unwrap the Error::Bug variant, panic otherwise
Sourcepub fn unwrap_source(self) -> Box<dyn StdError + 'static>
pub fn unwrap_source(self) -> Box<dyn StdError + 'static>
Unwrap the source of either Error::Domain or Error::Bug variant, panic otherwise
Trait Implementations§
Source§impl<D> Error for Error<D>where
D: Domain,
impl<D> Error for Error<D>where
D: Domain,
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
fn source(&self) -> Option<&(dyn StdError + 'static)>
Returns 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()
Auto Trait Implementations§
impl<D> !Freeze for Error<D>
impl<D> !RefUnwindSafe for Error<D>
impl<D> !Send for Error<D>
impl<D> !Sync for Error<D>
impl<D> Unpin for Error<D>
impl<D> !UnwindSafe for Error<D>
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