pub enum CliError {
Show 19 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),
ThreadPoolError {
message: String,
requested_threads: usize,
},
GlobPattern {
pattern: String,
message: String,
},
NoFilesMatched {
patterns: Vec<String>,
},
DirectoryTraversal {
path: PathBuf,
message: String,
},
ResourceExhaustion {
resource_type: String,
message: String,
current_usage: u64,
limit: u64,
},
}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.
ThreadPoolError
Thread pool creation error.
This occurs when creating a local Rayon thread pool fails, typically due to invalid configuration (e.g., zero threads) or resource exhaustion.
§Context
message- Detailed error message from Rayonrequested_threads- The number of threads requested
§Examples
use hedl_cli::error::CliError;
// Requesting zero threads is invalid
let err = CliError::thread_pool_error("thread count must be positive", 0);Fields
GlobPattern
Invalid glob pattern.
This error occurs when a glob pattern is malformed or contains invalid syntax.
§Examples
use hedl_cli::error::CliError;
let err = CliError::GlobPattern {
pattern: "[invalid".to_string(),
message: "unclosed character class".to_string(),
};NoFilesMatched
No files matched the provided patterns.
This error occurs when glob patterns don’t match any files.
§Examples
use hedl_cli::error::CliError;
let err = CliError::NoFilesMatched {
patterns: vec!["*.hedl".to_string(), "test/*.hedl".to_string()],
};DirectoryTraversal
Directory traversal error.
This error occurs when directory traversal fails due to permissions, I/O errors, or other filesystem issues.
§Examples
use hedl_cli::error::CliError;
use std::path::PathBuf;
let err = CliError::DirectoryTraversal {
path: PathBuf::from("/restricted"),
message: "permission denied".to_string(),
};ResourceExhaustion
Resource exhaustion error.
This error occurs when system resources are exhausted (e.g., file handles, memory).
§Examples
use hedl_cli::error::CliError;
let err = CliError::ResourceExhaustion {
resource_type: "file_handles".to_string(),
message: "too many open files".to_string(),
current_usage: 1024,
limit: 1024,
};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
Sourcepub fn invalid_input(msg: impl Into<String>) -> Self
pub fn invalid_input(msg: impl Into<String>) -> Self
Sourcepub fn json_conversion(msg: impl Into<String>) -> Self
pub fn json_conversion(msg: impl Into<String>) -> Self
Sourcepub fn yaml_conversion(msg: impl Into<String>) -> Self
pub fn yaml_conversion(msg: impl Into<String>) -> Self
Sourcepub fn xml_conversion(msg: impl Into<String>) -> Self
pub fn xml_conversion(msg: impl Into<String>) -> Self
Sourcepub fn csv_conversion(msg: impl Into<String>) -> Self
pub fn csv_conversion(msg: impl Into<String>) -> Self
Sourcepub fn parquet_conversion(msg: impl Into<String>) -> Self
pub fn parquet_conversion(msg: impl Into<String>) -> Self
Sourcepub fn thread_pool_error(
msg: impl Into<String>,
requested_threads: usize,
) -> Self
pub fn thread_pool_error( msg: impl Into<String>, requested_threads: usize, ) -> Self
Sourcepub fn similar_to(&self, other: &CliError) -> bool
pub fn similar_to(&self, other: &CliError) -> bool
Check if two errors are similar for grouping purposes.
Errors are considered similar if they have the same variant type, allowing aggregation of similar errors in batch processing.
§Examples
use hedl_cli::error::CliError;
let err1 = CliError::parse("syntax error");
let err2 = CliError::parse("unexpected token");
assert!(err1.similar_to(&err2));
let err3 = CliError::NotCanonical;
assert!(!err1.similar_to(&err3));Sourcepub fn category(&self) -> ErrorCategory
pub fn category(&self) -> ErrorCategory
Get the error category for reporting.
Categorizes errors into broad types for summary reporting.
§Examples
use hedl_cli::error::{CliError, ErrorCategory};
let err = CliError::parse("syntax error");
assert!(matches!(err.category(), ErrorCategory::ParseError));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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more