Skip to main content

CliError

Enum CliError 

Source
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.

Fields

§path: PathBuf

The file path that caused the error

§message: String

The error 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

§path: PathBuf

The file path that exceeded the limit

§actual: u64

The actual file size in bytes

§max: u64

The maximum allowed file size in bytes

§max_mb: u64

The maximum allowed file size in MB (for display)

§

IoTimeout

I/O operation timed out.

This prevents indefinite hangs on slow or unresponsive filesystems.

Fields

§path: PathBuf

The file path that timed out

§timeout_secs: u64

The timeout duration in seconds

§

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.

Fields

§message: String

The error message

§

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 Rayon
  • requested_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

§message: String

The error message from Rayon

§requested_threads: usize

The number of threads requested

§

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(),
};

Fields

§pattern: String

The invalid pattern

§message: String

The error message

§

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()],
};

Fields

§patterns: Vec<String>

The patterns that didn’t match any files

§

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(),
};

Fields

§path: PathBuf

The directory path that caused the error

§message: String

The error message

§

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,
};

Fields

§resource_type: String

The type of resource exhausted

§message: String

The error message

§current_usage: u64

Current resource usage

§limit: u64

Resource limit

Implementations§

Source§

impl CliError

Source

pub fn io_error(path: impl Into<PathBuf>, source: Error) -> Self

Create an I/O error with file path context.

§Arguments
  • path - The file path that caused the error
  • source - The underlying I/O error
§Examples
use hedl_cli::error::CliError;
use std::fs;

let result = fs::read_to_string("file.hedl")
    .map_err(|e| CliError::io_error("file.hedl", e));
Source

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 limit
  • actual - The actual file size in bytes
  • max - 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);
Source

pub fn io_timeout(path: impl Into<PathBuf>, timeout_secs: u64) -> Self

Create an I/O timeout error.

§Arguments
  • path - The file path that timed out
  • timeout_secs - The timeout duration in seconds
§Examples
use hedl_cli::error::CliError;

let err = CliError::io_timeout("/slow/filesystem/file.hedl", 30);
Source

pub fn parse(msg: impl Into<String>) -> Self

Create a parse error.

§Arguments
  • msg - The parse error message
Source

pub fn canonicalization(msg: impl Into<String>) -> Self

Create a canonicalization error.

§Arguments
  • msg - The canonicalization error message
Source

pub fn invalid_input(msg: impl Into<String>) -> Self

Create an invalid input error.

§Arguments
  • msg - Description of the invalid input
§Examples
use hedl_cli::error::CliError;

let err = CliError::invalid_input("Type name must be alphanumeric");
Source

pub fn json_conversion(msg: impl Into<String>) -> Self

Create a JSON conversion error.

§Arguments
  • msg - The JSON conversion error message
Source

pub fn yaml_conversion(msg: impl Into<String>) -> Self

Create a YAML conversion error.

§Arguments
  • msg - The YAML conversion error message
Source

pub fn xml_conversion(msg: impl Into<String>) -> Self

Create an XML conversion error.

§Arguments
  • msg - The XML conversion error message
Source

pub fn csv_conversion(msg: impl Into<String>) -> Self

Create a CSV conversion error.

§Arguments
  • msg - The CSV conversion error message
Source

pub fn parquet_conversion(msg: impl Into<String>) -> Self

Create a Parquet conversion error.

§Arguments
  • msg - The Parquet conversion error message
Source

pub fn thread_pool_error( msg: impl Into<String>, requested_threads: usize, ) -> Self

Create a thread pool error.

§Arguments
  • msg - The error message from Rayon
  • requested_threads - The number of threads requested
§Examples
use hedl_cli::error::CliError;

let err = CliError::thread_pool_error("thread count must be positive", 0);
Source

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));
Source

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 Clone for CliError

Source§

fn clone(&self) -> CliError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CliError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CliError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for CliError

1.30.0 · Source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for CliError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

Source§

impl<T> ToLine for T
where T: Display,

Source§

fn to_line(&self) -> Line<'_>

Converts the value to a Line.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToSpan for T
where T: Display,

Source§

fn to_span(&self) -> Span<'_>

Converts the value to a Span.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> ToText for T
where T: Display,

Source§

fn to_text(&self) -> Text<'_>

Converts the value to a Text.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,