pub enum Error {
CommandNotFound {
command: String,
suggestions: Vec<String>,
},
SubcommandRequired(String),
NoRunFunction(String),
FlagParsing {
message: String,
flag: Option<String>,
suggestions: Vec<String>,
},
ArgumentParsing(String),
ArgumentValidation {
message: String,
expected: String,
received: usize,
},
Validation(String),
Completion(String),
Io(Error),
Custom(Box<dyn Error + Send + Sync>),
}Expand description
The main error type for the flag framework
This enum represents all possible errors that can occur during command parsing, validation, and execution.
Variants§
CommandNotFound
The specified command was not found
This error occurs when a user tries to run a subcommand that doesn’t exist.
Fields
SubcommandRequired(String)
A command requires a subcommand but none was provided
This error occurs when a parent command has no run function and the user doesn’t specify which subcommand to run. Contains the parent command name.
NoRunFunction(String)
A command has no run function defined
This error occurs when trying to execute a command that has no run handler. Contains the command name.
FlagParsing
An error occurred while parsing flag values
This error occurs when a flag value cannot be parsed as the expected type (e.g., “abc” for an integer flag).
Fields
ArgumentParsing(String)
An error occurred while parsing command arguments
This error occurs when command arguments don’t meet requirements. Contains a description of the error.
ArgumentValidation
Argument validation failed
This error occurs when arguments don’t meet validation constraints.
Fields
Validation(String)
A validation error occurred
This error occurs when custom validation logic fails. Contains a description of the validation failure.
Completion(String)
An error occurred during shell completion
This error occurs when completion functions fail. Contains a description of the error.
Io(Error)
An I/O error occurred
Wraps standard I/O errors that may occur during command execution.
Custom(Box<dyn Error + Send + Sync>)
A custom error from user code
Allows command handlers to return their own error types.