Struct clierr::Error
[−]
[src]
pub struct Error { // some fields omitted }
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.
Methods
impl Error
[src]
fn new<S, E>(description: S, cause: E) -> Error where S: Into<Cow<'static, str>>, E: StdError + 'static
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);
fn with_description<S: Into<Cow<'static, str>>>(description: S) -> Error
Creates a new error with a descrption but no cause. Useful for validation specific errors where there's no underlying error (e.g. CLI timeout argument must be greater than zero).
fn caused_by<E: StdError + 'static>(cause: E) -> Error
Creates a new error with a cause, but no description. The Display
implementation
forwards to that of cause
in this case.
In most cases you'll want to use the convenient DescribeErr
trait or the ctry
and ccheck
macros instead.