pub enum ConfigError {
FileNotFound {
path: PathBuf,
},
UnsupportedFormat {
extension: String,
},
YamlParse {
source: Error,
line: Option<usize>,
column: Option<usize>,
},
JsonParse {
source: Error,
line: usize,
column: usize,
},
InvalidSchema {
reason: String,
path: Option<String>,
},
DuplicateCommand {
name: String,
},
UnknownType {
type_name: String,
context: String,
},
Inconsistency {
details: String,
},
}Expand description
Errors related to loading and parsing the configuration file
These errors occur when loading the commands.yaml or commands.json
file and its structural validation.
Variants§
FileNotFound
Configuration file not found
§Example
use dynamic_cli::error::ConfigError;
use std::path::PathBuf;
let error = ConfigError::FileNotFound {
path: PathBuf::from("missing.yaml"),
};UnsupportedFormat
Unsupported file extension
Only .yaml, .yml and .json are supported.
YamlParse
YAML parsing error
JsonParse
JSON parsing error
InvalidSchema
Invalid configuration schema
The file structure doesn’t match the expected format.
DuplicateCommand
Duplicate command (same name or alias)
UnknownType
Unknown argument type
Inconsistency
Inconsistent configuration
For example, a default value that’s not in the allowed choices.
Implementations§
Source§impl ConfigError
impl ConfigError
Sourcepub fn yaml_parse_with_location(source: Error) -> Self
pub fn yaml_parse_with_location(source: Error) -> Self
Create a YAML error with position
Extracts position information from the serde_yaml error.
Sourcepub fn json_parse_with_location(source: Error) -> Self
pub fn json_parse_with_location(source: Error) -> Self
Create a JSON error with position
Extracts position information from the serde_json error.
Trait Implementations§
Source§impl Debug for ConfigError
impl Debug for ConfigError
Source§impl Display for ConfigError
impl Display for ConfigError
Source§impl Error for ConfigError
impl Error for ConfigError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<ConfigError> for DynamicCliError
impl From<ConfigError> for DynamicCliError
Source§fn from(source: ConfigError) -> Self
fn from(source: ConfigError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ConfigError
impl !RefUnwindSafe for ConfigError
impl Send for ConfigError
impl Sync for ConfigError
impl Unpin for ConfigError
impl !UnwindSafe for ConfigError
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
Mutably borrows from an owned value. Read more