Enum lexopt::Error

source ·
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

Fields

§option: Option<String>

The most recently emitted option.

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

Fields

§option: String

The option.

§value: OsString

The value.

An option had a value when none was expected.

§

ParsingFailed

Fields

§value: String

The string that failed to parse.

§error: Box<dyn Error + Send + Sync + 'static>

The error returned while parsing.

Parsing a value failed. Returned by methods on ValueExt.

§

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§

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
Converts to this type from the input type.

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.

Converts to this type from the input type.
Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to provide by using demand. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.