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
27
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
    #[error("internal I/O error")]
    IO(#[from] std::io::Error),

    #[error("decoded variable integer size was outside of expected bounds of {0} bits")]
    VarIntSizeExceeded(u8),

    #[error("while trying to read more data (expected: {0} bytes), an unexpected end of buffer was reached")]
    EndOfBuffer(usize),

    #[error("while reading, an unexpected value was found")]
    UnexpectedValue,

    #[error("`{0}`")]
    Other(String),

    #[cfg(not(feature = "lib0-serde"))]
    #[error("JSON parsing error: {0}")]
    InvalidJSON(#[from] crate::json_parser::JsonParseError),

    #[cfg(feature = "lib0-serde")]
    #[error("JSON parsing error: {0}")]
    InvalidJSON(#[from] serde_json::Error),
}