pub enum RegistryError {
DuplicateRegistration {
name: String,
suggestion: Option<String>,
},
DuplicateAlias {
alias: String,
existing_command: String,
suggestion: Option<String>,
},
MissingHandler {
command: String,
suggestion: Option<String>,
},
FaultToleranceMismatch {
command: String,
expected: bool,
configured: bool,
suggestion: Option<String>,
},
}Expand description
Errors related to the command registry
These errors occur when registering commands and handlers in the registry.
Variants§
DuplicateRegistration
Attempt to register an already existing command
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::DuplicateRegistration {
name: "run".to_string(),
suggestion: Some("Command names must be unique across the registry.".to_string()),
};
let msg = format!("{}", error);
assert!(msg.contains("run"));Fields
DuplicateAlias
Alias already used by another command
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::DuplicateAlias {
alias: "r".to_string(),
existing_command: "run".to_string(),
suggestion: Some("Choose a different alias for one of the commands.".to_string()),
};
let msg = format!("{}", error);
assert!(msg.contains("run"));Fields
MissingHandler
Missing handler for a definition
A command is defined in the config but no handler has been registered for it.
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::MissingHandler {
command: "export".to_string(),
suggestion: Some(
"Call .register_sync_handler(\"export\", ...) before running.".to_string()
),
};
let msg = format!("{}", error);
assert!(msg.contains("export"));Fields
FaultToleranceMismatch
A handler’s declared expected_fault_tolerance() contradicts the
command’s configured continue_on_failure
Raised by CommandRegistry::register_sync/register_async when the
handler expresses an opinion (Some(bool)) that disagrees with the
YAML value — catching a misconfiguration at startup rather than at
first use in a chain. Never raised when the handler expresses no
opinion (None, the default).
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::FaultToleranceMismatch {
command: "solve".to_string(),
expected: false,
configured: true,
suggestion: Some(
"set `continue_on_failure: false` for command 'solve' in the \
YAML config, matching what its handler expects".to_string()
),
};
let msg = format!("{}", error);
assert!(msg.contains("solve"));Implementations§
Source§impl RegistryError
impl RegistryError
Sourcepub fn missing_handler(command: &str) -> Self
pub fn missing_handler(command: &str) -> Self
Create a missing-handler error with an actionable suggestion
The suggestion interpolates the command name so the user
knows exactly which .register_sync_handler() call is missing.
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::missing_handler("export");
match error {
RegistryError::MissingHandler { suggestion, .. } => {
assert!(suggestion.as_deref().unwrap_or("").contains("export"));
}
_ => panic!("wrong variant"),
}Sourcepub fn fault_tolerance_mismatch(
command: &str,
expected: bool,
configured: bool,
) -> Self
pub fn fault_tolerance_mismatch( command: &str, expected: bool, configured: bool, ) -> Self
Create a fault-tolerance-mismatch error with an actionable suggestion
expected is what the handler’s expected_fault_tolerance()
returned; configured is the command’s actual
CommandDefinition::continue_on_failure. The suggestion tells the
user exactly which YAML value to change to resolve the contradiction.
§Example
use dynamic_cli::error::RegistryError;
let error = RegistryError::fault_tolerance_mismatch("solve", false, true);
match error {
RegistryError::FaultToleranceMismatch { suggestion, .. } => {
assert!(suggestion.as_deref().unwrap_or("").contains("continue_on_failure: false"));
}
_ => panic!("wrong variant"),
}Trait Implementations§
Source§impl Debug for RegistryError
impl Debug for RegistryError
Source§impl Display for RegistryError
impl Display for RegistryError
Source§impl Error for RegistryError
impl Error for RegistryError
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()
Source§impl From<RegistryError> for DynamicCliError
impl From<RegistryError> for DynamicCliError
Source§fn from(source: RegistryError) -> Self
fn from(source: RegistryError) -> Self
Auto Trait Implementations§
impl Freeze for RegistryError
impl RefUnwindSafe for RegistryError
impl Send for RegistryError
impl Sync for RegistryError
impl Unpin for RegistryError
impl UnsafeUnpin for RegistryError
impl UnwindSafe for RegistryError
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more