pub enum CliError {
Show 14 variants
Io {
path: PathBuf,
message: String,
},
FileTooLarge {
path: PathBuf,
actual: u64,
max: u64,
max_mb: u64,
},
IoTimeout {
path: PathBuf,
timeout_secs: u64,
},
Parse(String),
Canonicalization(String),
JsonConversion(String),
JsonFormat {
message: String,
},
YamlConversion(String),
XmlConversion(String),
CsvConversion(String),
ParquetConversion(String),
LintErrors,
NotCanonical,
InvalidInput(String),
}Expand description
The main error type for HEDL CLI operations.
This enum represents all possible error conditions that can occur during CLI command execution. Each variant provides rich context for debugging and user-friendly error messages.
§Cloning
Implements Clone to support parallel error handling in multi-threaded
operations.
§Examples
use hedl_cli::error::CliError;
fn read_and_parse(path: &str) -> Result<(), CliError> {
// Error is automatically converted and contextualized
let content = std::fs::read_to_string(path)
.map_err(|e| CliError::io_error(path, e))?;
Ok(())
}Variants§
Io
I/O operation failed (file read, write, or metadata access).
This error includes the file path and the error kind/message.
FileTooLarge
File size exceeds the maximum allowed limit (100 MB).
This prevents denial-of-service attacks via memory exhaustion. The error includes the actual file size and the configured limit.
Fields
IoTimeout
I/O operation timed out.
This prevents indefinite hangs on slow or unresponsive filesystems.
Parse(String)
HEDL parsing error.
This wraps errors from the hedl-core parser with additional context.
Canonicalization(String)
HEDL canonicalization error.
This wraps errors from the hedl-c14n canonicalizer.
JsonConversion(String)
JSON conversion error.
This includes both HEDL→JSON and JSON→HEDL conversion errors.
JsonFormat
JSON serialization/deserialization error.
This wraps serde_json errors during formatting.
YamlConversion(String)
YAML conversion error.
This includes both HEDL→YAML and YAML→HEDL conversion errors.
XmlConversion(String)
XML conversion error.
This includes both HEDL→XML and XML→HEDL conversion errors.
CsvConversion(String)
CSV conversion error.
This includes both HEDL→CSV and CSV→HEDL conversion errors.
ParquetConversion(String)
Parquet conversion error.
This includes both HEDL→Parquet and Parquet→HEDL conversion errors.
LintErrors
Linting error.
This indicates that linting found issues that should cause failure.
NotCanonical
File is not in canonical form.
This is returned by the format --check command.
InvalidInput(String)
Invalid input provided by the user.
This covers validation failures like invalid type names, empty files, etc.
Implementations§
Source§impl CliError
impl CliError
Sourcepub fn file_too_large(path: impl Into<PathBuf>, actual: u64, max: u64) -> Self
pub fn file_too_large(path: impl Into<PathBuf>, actual: u64, max: u64) -> Self
Create a file-too-large error.
§Arguments
path- The file path that exceeded the limitactual- The actual file size in bytesmax- The maximum allowed file size in bytes
§Examples
use hedl_cli::error::CliError;
const MAX_SIZE: u64 = 100 * 1024 * 1024; // 100 MB
let err = CliError::file_too_large("huge.hedl", 200_000_000, MAX_SIZE);Sourcepub fn io_timeout(path: impl Into<PathBuf>, timeout_secs: u64) -> Self
pub fn io_timeout(path: impl Into<PathBuf>, timeout_secs: u64) -> Self
Sourcepub fn canonicalization(msg: impl Into<String>) -> Self
pub fn canonicalization(msg: impl Into<String>) -> Self
Trait Implementations§
Source§impl Error for CliError
impl Error for CliError
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
Auto Trait Implementations§
impl Freeze for CliError
impl RefUnwindSafe for CliError
impl Send for CliError
impl Sync for CliError
impl Unpin for CliError
impl UnwindSafe for CliError
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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