Skip to main content

reconcile_text/operation_transformation/
diff_error.rs

1use thiserror::Error;
2
3/// Error type for invalid diff operations
4#[derive(Error, Debug, Clone, PartialEq)]
5pub enum DiffError {
6    /// The diff references a range that exceeds the original text length
7    #[error(
8        "Invalid diff: attempting to access {requested} characters starting at position \
9         {position}, but original text only has {available} characters remaining"
10    )]
11    LengthExceedsOriginal {
12        /// The position where the operation starts
13        position: usize,
14        /// The number of characters requested
15        requested: usize,
16        /// The number of characters available from the position
17        available: usize,
18    },
19
20    /// A character count was too large to represent as i64
21    #[error("Integer overflow: value {value} cannot be represented as i64")]
22    IntegerOverflow {
23        /// The value that caused the overflow
24        value: usize,
25    },
26}