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

#[derive(Debug, Error)]
#[non_exhaustive]
pub enum CodecError {
    #[error("provided input was too short")]
    InputTooShort,

    #[error("container size too large (entries {0})")]
    ContainerTooLarge(usize),

    #[error("bytes leftover in container ({0} remaining in {1})")]
    LeftoverBytes(usize, usize),

    #[error("tried to parse non-UTF-8 bytes as string")]
    NonUtf8String,

    #[cfg(feature = "as-borsh")]
    #[error("borsh: {0}")]
    Borsh(borsh::io::Error),

    #[cfg(feature = "as-serde-cbor")]
    #[error("cbor: {0}")]
    SerdeCbor(serde_cbor::error::Error),

    #[cfg(feature = "as-serde-json")]
    #[error("json: {0}")]
    SerdeJson(serde_json::Error),
}