serde_json_diagnostics 0.1.0

Enhanced deserialization error diagnostics for serde_json with accurate JSON path tracking
Documentation
//! Error types for JSON deserialization diagnostics.

use std::error::Error as StdError;
use std::fmt;

/// Enhanced error type with path tracking for JSON deserialization errors.
///
/// This type wraps serde_json::Error and adds path information to help identify
/// where in the JSON structure a deserialization error occurred. Path tracking
/// implementation is pending completion in Phase 4.
#[derive(Debug)]
pub struct ErrorDiagnostic {
    /// The underlying serde_json error
    inner: serde_json::Error,
}

/// Type alias for Result with ErrorDiagnostic as the error type.
pub type Result<T> = std::result::Result<T, ErrorDiagnostic>;

impl ErrorDiagnostic {
    /// Create a new ErrorDiagnostic from a serde_json::Error.
    pub(crate) fn new(inner: serde_json::Error) -> Self {
        ErrorDiagnostic { inner }
    }
}

impl fmt::Display for ErrorDiagnostic {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        write!(f, "{}", self.inner)
    }
}

impl StdError for ErrorDiagnostic {
    fn source(&self) -> Option<&(dyn StdError + 'static)> {
        self.inner.source()
    }
}