pub enum Error {
MissingValue {
option: Option<String>,
},
UnexpectedOption(String),
UnexpectedArgument(OsString),
UnexpectedValue {
option: String,
value: OsString,
},
ParsingFailed {
value: String,
error: Box<dyn Error + Send + Sync + 'static>,
},
NonUnicodeValue(OsString),
Custom(Box<dyn Error + Send + Sync + 'static>),
}
Expand description
An error during argument parsing.
This implements From<String>
and From<&str>
, for easy ad-hoc error
messages.
Variants§
MissingValue
An option argument was expected but was not found.
UnexpectedOption(String)
An unexpected option was found.
UnexpectedArgument(OsString)
A positional argument was found when none was expected.
UnexpectedValue
An option had a value when none was expected.
ParsingFailed
Parsing a value failed. Returned by methods on ValueExt
.
Fields
NonUnicodeValue(OsString)
A value was found that was not valid unicode.
This can be returned by the methods on ValueExt
.
Custom(Box<dyn Error + Send + Sync + 'static>)
For custom error messages in application code.
Trait Implementations§
source§impl Error for Error
impl Error for Error
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
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()
source§impl From<OsString> for Error
impl From<OsString> for Error
For OsString::into_string
, so it may be used with the try (?
) operator.
ValueExt::string
is the new preferred method because it’s compatible with
catch-all error types like anyhow::Error
.
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