#
rustfix/
error.rs

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26

    //! Error types.

    use std::ops::Range;

    #[non_exhaustive]
    #[derive(Debug, thiserror::Error)]
    pub enum Error {
        #[error("invalid range {0:?}, start is larger than end")]
        InvalidRange(Range<usize>),

        #[error("invalid range {0:?}, original data is only {1} byte long")]
        DataLengthExceeded(Range<usize>, usize),

        #[non_exhaustive]
        #[error("cannot replace slice of data that was already replaced")]
        AlreadyReplaced {
            /// The location of the intended replacement.
            range: Range<usize>,
            /// Whether the modification exactly matches (both range and data) the one it conflicts with.
            /// Some clients may wish to simply ignore this condition.
            is_identical: bool,
        },

        #[error(transparent)]
        Utf8(#[from] std::string::FromUtf8Error),
    }