Skip to main content

llm_diff/
error.rs

1// SPDX-License-Identifier: MIT
2use thiserror::Error;
3
4/// All errors that can occur in the llm-diff library.
5#[derive(Debug, Error)]
6pub enum DiffError {
7    /// A requested version ID was not found in the store.
8    #[error("Version '{0}' not found in store")]
9    VersionNotFound(String),
10    /// A rollback target version has no accessible path.
11    #[error("Cannot rollback to version '{0}': no path exists")]
12    RollbackFailed(String),
13    /// An output exceeded the configured token size limit.
14    #[error("Output too large: {size} tokens exceeds limit {limit}")]
15    OutputTooLarge { size: usize, limit: usize },
16    /// JSON serialization or deserialization failed.
17    #[error("Serialization error: {0}")]
18    Serialization(#[from] serde_json::Error),
19    /// A diff was structurally invalid.
20    #[error("Invalid diff: {0}")]
21    InvalidDiff(String),
22    /// Two different versions mapped to the same content address.
23    #[error("Content address collision for '{0}'")]
24    ContentAddressCollision(String),
25    /// A branch name was not found in the store.
26    #[error("Branch '{0}' not found")]
27    BranchNotFound(String),
28}