pub enum Error {
Show 13 variants
UnknownOption(String),
UnknownSubcommand {
name: String,
available: Vec<String>,
},
MissingValue(String),
UnexpectedValue(String),
MissingOption(String),
MissingArgument(String),
MissingSubcommand {
available: Vec<String>,
},
ExtraArgument(String),
InvalidValue {
name: String,
value: String,
message: String,
},
HelpRequested,
InSubcommand {
path: Vec<String>,
source: Box<Error>,
},
Runtime(Box<Error>),
Custom(String),
}Expand description
Errors produced by the launcher when parsing command-line arguments.
Variants§
UnknownOption(String)
UnknownSubcommand
MissingValue(String)
UnexpectedValue(String)
MissingOption(String)
A required option was not provided at all (distinct from
MissingValue, which fires when the option name was typed without a
following value).
MissingArgument(String)
MissingSubcommand
ExtraArgument(String)
InvalidValue
HelpRequested
Sentinel used internally when the user passes -h/--help.
InSubcommand
Wraps an error produced while parsing a subcommand so the launcher can
print the right (sub)command help. path is the chain from the root
schema to the failing subcommand, newest-last.
Runtime(Box<Error>)
Wraps an error returned by a subcommand’s run method. The launcher
uses this to distinguish user runtime failures from parse-origin
errors. It matters because SubCommandOf::run may legitimately
reuse parse-origin variants (e.g. MissingArgument) for its own
post-parse validation, so variant-based classification alone is
not enough.
Custom(String)
Implementations§
Source§impl Error
impl Error
pub fn invalid_value( name: impl Into<String>, value: impl Into<String>, message: impl Into<String>, ) -> Self
pub fn custom(message: impl Into<String>) -> Self
Sourcepub fn is_parse_error(&self) -> bool
pub fn is_parse_error(&self) -> bool
Whether this error originated from argument parsing (as opposed to a user command’s runtime logic). The launcher uses this to decide whether to print help text alongside the error message.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()