pub struct Error { /* private fields */ }
Expand description
A minimalist error type to use in CLI scripts: it wraps an arbitrary cause which implements
std::error::Error
and a description for the Display
implementation.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new<S, E>(description: S, cause: E) -> Error
pub fn new<S, E>(description: S, cause: E) -> Error
Creates a new Error
with a description and a cause.
In most cases you’ll want to use the convenient DescribeErr
trait or the ctry
and ccheck
macros.
With a &'static str
:
Error::new("oh no!", some_error);
With a String
:
Error::new(format!("should not have tried to open '{}'!", filename), some_error);
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§fn cause(&self) -> Option<&dyn StdError>
fn cause(&self) -> Option<&dyn StdError>
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl !Send for Error
impl !Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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