Enum ErrorKind
enum ErrorKind
Command line argument parser kind of error
Variants
-
InvalidValue Occurs when an [
Arg][crate::Arg] has a set of possible values, and the user provides a value which isn't in that set.Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
UnknownArgument Occurs when a user provides a flag, option, argument or subcommand which isn't defined.
Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
InvalidSubcommand Occurs when the user provides an unrecognized
Subcommandwhich meets the threshold for being similar enough to an existing subcommand. If it doesn't meet the threshold, or the 'suggestions' feature is disabled, the more generalUnknownArgumenterror is returned.Examples
#-
NoEquals Occurs when the user doesn't use equals for an option that requires equal sign to provide values.
# use clap_builder as clap; # use ; let res = new .arg .try_get_matches_from; assert!; assert_eq!;-
ValueValidation Occurs when the user provides a value for an argument with a custom validation and the value fails that validation.
Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
TooManyValues Occurs when a user provides more values for an argument than were defined by setting
Arg::num_args.Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
TooFewValues Occurs when the user provides fewer values for an argument than were defined by setting
Arg::num_args.Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
WrongNumberOfValues Occurs when the user provides a different number of values for an argument than what's been defined by setting
Arg::num_argsor than was implicitly set byArg::value_names.Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
ArgumentConflict Occurs when the user provides two values which conflict with each other and can't be used together.
Examples
# use clap_builder as clap; # use ; let result = new .arg .arg .try_get_matches_from; assert!; assert_eq!;-
MissingRequiredArgument Occurs when the user does not provide one or more required arguments.
Examples
# use clap_builder as clap; # use ; let result = new .arg .try_get_matches_from; assert!; assert_eq!;-
MissingSubcommand Occurs when a subcommand is required (as defined by
Command::subcommand_required), but the user does not provide one.Examples
# use clap_builder as clap; # use ; let err = new .subcommand_required .subcommand .try_get_matches_from; assert!; assert_eq!; # ;-
InvalidUtf8 Occurs when the user provides a value containing invalid UTF-8.
To allow arbitrary data
- Set [
Arg::value_parser(value_parser!(OsString))] for argument values - Set
Command::external_subcommand_value_parserfor external-subcommand values
Platform Specific
Non-Windows platforms only (such as Linux, Unix, OSX, etc.)
Examples
#- Set [
-
DisplayHelp Not a true "error" as it means
--helpor similar was used. The help message will be sent tostdout.Note: If the help is displayed due to an error (such as missing subcommands) it will be sent to
stderrinstead ofstdout.Examples
#-
DisplayHelpOnMissingArgumentOrSubcommand Occurs when either an argument or a
Subcommandis required, as defined byCommand::arg_required_else_help, but the user did not provide one.Examples
# use clap_builder as clap; # use ; let result = new .arg_required_else_help .subcommand .try_get_matches_from; assert!; assert_eq!;-
DisplayVersion Not a true "error" as it means
--versionor similar was used. The message will be sent tostdout.Examples
# use clap_builder as clap; # use ; let result = new .version .try_get_matches_from; assert!; assert_eq!;-
Io Represents an I/O error. Can occur when writing to
stderrorstdoutor reading a configuration file.-
Format Represents a Format error (which is a part of
Display). Typically caused by writing tostderrorstdout.
Implementations
impl ErrorKind
fn as_str(self: Self) -> Option<&'static str>End-user description of the error case, where relevant
impl Clone for ErrorKind
fn clone(self: &Self) -> ErrorKind
impl Copy for ErrorKind
impl Debug for ErrorKind
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Display for ErrorKind
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Eq for ErrorKind
impl Freeze for ErrorKind
impl Hash for ErrorKind
fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)
impl PartialEq for ErrorKind
fn eq(self: &Self, other: &ErrorKind) -> bool
impl RefUnwindSafe for ErrorKind
impl Send for ErrorKind
impl StructuralPartialEq for ErrorKind
impl Sync for ErrorKind
impl Unpin for ErrorKind
impl UnsafeUnpin for ErrorKind
impl UnwindSafe for ErrorKind
impl<T> Any for ErrorKind
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for ErrorKind
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for ErrorKind
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for ErrorKind
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for ErrorKind
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for ErrorKind
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T> ToString for ErrorKind
fn to_string(self: &Self) -> String
impl<T, U> Into for ErrorKind
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for ErrorKind
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for ErrorKind
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>