toon_core/error.rs
1//! Error types for TOON encoding and decoding operations.
2
3use thiserror::Error;
4
5/// Errors that can occur during TOON encoding or decoding.
6#[derive(Error, Debug)]
7pub enum ToonError {
8 /// The input string was not valid JSON (encoding path).
9 #[error("JSON parse error: {0}")]
10 JsonParse(#[from] serde_json::Error),
11
12 /// The input string was not valid TOON (decoding path).
13 /// Includes the 1-based line number where the error was detected.
14 #[error("TOON parse error at line {line}: {message}")]
15 ToonParse { line: usize, message: String },
16
17 /// A structural error during encoding (e.g., unsupported value type).
18 #[error("Encoding error: {0}")]
19 Encode(String),
20}
21
22/// Convenience alias used throughout temporal-cortex-toon.
23pub type Result<T> = std::result::Result<T, ToonError>;