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
Validation
Validation error (strict mode violations)
EventStream
Event stream processing error
PathExpansion
Path expansion conflict or error
Io
I/O error with operation context
Json
JSON serialization/deserialization error
Message
Generic message (for backward compatibility)
Implementations§
Source§impl ToonError
impl ToonError
Sourcepub fn message(message: impl Into<String>) -> Self
pub fn message(message: impl Into<String>) -> Self
Create a generic message error (backward compatible).
Sourcepub fn parse(line: usize, message: impl Into<String>) -> Self
pub fn parse(line: usize, message: impl Into<String>) -> Self
Create a parse error with line number.
Sourcepub fn unterminated_string(line: usize) -> Self
pub fn unterminated_string(line: usize) -> Self
Create a parse error for unterminated string.
Sourcepub fn missing_colon(line: usize) -> Self
pub fn missing_colon(line: usize) -> Self
Create a parse error for missing colon after key.
Sourcepub fn invalid_array_length(line: usize, value: &str) -> Self
pub fn invalid_array_length(line: usize, value: &str) -> Self
Create a parse error for invalid array length.
Sourcepub fn validation(line: usize, message: impl Into<String>) -> Self
pub fn validation(line: usize, message: impl Into<String>) -> Self
Create a validation error with line number.
Sourcepub fn tabs_not_allowed(line: usize) -> Self
pub fn tabs_not_allowed(line: usize) -> Self
Create a validation error for tabs in indentation.
Sourcepub fn invalid_indentation(line: usize, expected: usize, found: usize) -> Self
pub fn invalid_indentation(line: usize, expected: usize, found: usize) -> Self
Create a validation error for incorrect indentation.
Sourcepub fn event_stream(message: impl Into<String>) -> Self
pub fn event_stream(message: impl Into<String>) -> Self
Create an event stream error.
Sourcepub fn mismatched_end(expected: &str, found: &str) -> Self
pub fn mismatched_end(expected: &str, found: &str) -> Self
Create an error for mismatched end event.
Sourcepub fn unexpected_event(event: &str, context: &str) -> Self
pub fn unexpected_event(event: &str, context: &str) -> Self
Create an error for unexpected event.
Sourcepub fn path_expansion(
path: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn path_expansion( path: impl Into<String>, message: impl Into<String>, ) -> Self
Create a path expansion error.
Sourcepub fn path_conflict(path: &str, existing: &str) -> Self
pub fn path_conflict(path: &str, existing: &str) -> Self
Create an error for path conflict during expansion.
Sourcepub fn io(
operation: impl Into<String>,
path: Option<PathBuf>,
source: Error,
) -> Self
pub fn io( operation: impl Into<String>, path: Option<PathBuf>, source: Error, ) -> Self
Create an I/O error with path context.
Sourcepub fn file_write(path: PathBuf, source: Error) -> Self
pub fn file_write(path: PathBuf, source: Error) -> Self
Create an error for file write failure.
Sourcepub fn file_create(path: PathBuf, source: Error) -> Self
pub fn file_create(path: PathBuf, source: Error) -> Self
Create an error for file creation failure.
Sourcepub fn stdin_read(source: Error) -> Self
pub fn stdin_read(source: Error) -> Self
Create an error for stdin read failure.
Sourcepub fn stdout_write(source: Error) -> Self
pub fn stdout_write(source: Error) -> Self
Create an error for stdout write failure.
Sourcepub fn json_parse(err: &Error) -> Self
pub fn json_parse(err: &Error) -> Self
Create a JSON parse error.
Sourcepub fn json_stringify(err: &Error) -> Self
pub fn json_stringify(err: &Error) -> Self
Create a JSON stringify error.
Trait Implementations§
Source§impl Error for ToonError
impl Error for ToonError
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
use the Display impl or to_string()