veerdiff 0.1.0

Semantic diff engine for LLM and agent execution traces — find exactly where two runs veer apart.
Documentation
//! Error types for the `veer` library.

use std::fmt;

/// Errors that can occur while importing, normalizing, or diffing traces.
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
    /// The input could not be parsed as JSON.
    #[error("invalid JSON: {0}")]
    Json(#[from] serde_json::Error),

    /// The JSON was valid but did not match the expected shape for a format.
    #[error("could not interpret input as a {format} trace: {reason}")]
    Shape {
        /// The format that was attempted.
        format: &'static str,
        /// A human-readable explanation of the mismatch.
        reason: String,
    },

    /// Automatic format detection failed to find a matching importer.
    #[error("could not auto-detect trace format; specify one explicitly")]
    UnknownFormat,

    /// A user-supplied regular expression could not be compiled.
    #[error("invalid pattern `{pattern}`: {reason}")]
    Pattern {
        /// The offending pattern.
        pattern: String,
        /// Why it failed to compile.
        reason: String,
    },

    /// A configuration value was invalid.
    #[error("invalid configuration: {0}")]
    Config(String),
}

impl Error {
    /// Construct a [`Error::Shape`] error.
    pub(crate) fn shape(format: &'static str, reason: impl fmt::Display) -> Self {
        Error::Shape {
            format,
            reason: reason.to_string(),
        }
    }
}

/// Convenience alias used throughout the crate.
pub type Result<T> = std::result::Result<T, Error>;