Skip to main content

ToonError

Enum ToonError 

Source
pub enum ToonError {
    Parse {
        line: usize,
        message: String,
    },
    Validation {
        line: usize,
        message: String,
    },
    EventStream {
        message: String,
    },
    PathExpansion {
        path: String,
        message: String,
    },
    Io {
        operation: String,
        path: Option<PathBuf>,
        source: Error,
    },
    Json {
        message: String,
    },
    Message {
        message: String,
    },
}
Expand description

Comprehensive error types for TOON encoding and decoding operations.

Variants§

§

Parse

Parse error with line number context

Fields

§line: usize
§message: String
§

Validation

Validation error (strict mode violations)

Fields

§line: usize
§message: String
§

EventStream

Event stream processing error

Fields

§message: String
§

PathExpansion

Path expansion conflict or error

Fields

§path: String
§message: String
§

Io

I/O error with operation context

Fields

§operation: String
§source: Error
§

Json

JSON serialization/deserialization error

Fields

§message: String
§

Message

Generic message (for backward compatibility)

Fields

§message: String

Implementations§

Source§

impl ToonError

Source

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

Create a generic message error (backward compatible).

Source

pub fn parse(line: usize, message: impl Into<String>) -> Self

Create a parse error with line number.

Source

pub fn unterminated_string(line: usize) -> Self

Create a parse error for unterminated string.

Source

pub fn missing_colon(line: usize) -> Self

Create a parse error for missing colon after key.

Source

pub fn invalid_array_length(line: usize, value: &str) -> Self

Create a parse error for invalid array length.

Source

pub fn validation(line: usize, message: impl Into<String>) -> Self

Create a validation error with line number.

Source

pub fn tabs_not_allowed(line: usize) -> Self

Create a validation error for tabs in indentation.

Source

pub fn invalid_indentation(line: usize, expected: usize, found: usize) -> Self

Create a validation error for incorrect indentation.

Source

pub fn event_stream(message: impl Into<String>) -> Self

Create an event stream error.

Source

pub fn mismatched_end(expected: &str, found: &str) -> Self

Create an error for mismatched end event.

Source

pub fn unexpected_event(event: &str, context: &str) -> Self

Create an error for unexpected event.

Source

pub fn path_expansion( path: impl Into<String>, message: impl Into<String>, ) -> Self

Create a path expansion error.

Source

pub fn path_conflict(path: &str, existing: &str) -> Self

Create an error for path conflict during expansion.

Source

pub fn io( operation: impl Into<String>, path: Option<PathBuf>, source: Error, ) -> Self

Create an I/O error with path context.

Source

pub fn file_read(path: PathBuf, source: Error) -> Self

Create an error for file read failure.

Source

pub fn file_write(path: PathBuf, source: Error) -> Self

Create an error for file write failure.

Source

pub fn file_create(path: PathBuf, source: Error) -> Self

Create an error for file creation failure.

Source

pub fn stdin_read(source: Error) -> Self

Create an error for stdin read failure.

Source

pub fn stdout_write(source: Error) -> Self

Create an error for stdout write failure.

Source

pub fn json(message: impl Into<String>) -> Self

Create a JSON error.

Source

pub fn json_parse(err: &Error) -> Self

Create a JSON parse error.

Source

pub fn json_stringify(err: &Error) -> Self

Create a JSON stringify error.

Trait Implementations§

Source§

impl Debug for ToonError

Source§

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

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

impl Display for ToonError

Source§

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

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

impl Error for ToonError

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 ToonError

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for ToonError

Source§

fn from(err: 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> 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> 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.