CliError

Enum CliError 

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

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.

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

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