ic_cbor/
error.rs

1pub type CborResult<T = ()> = Result<T, CborError>;
2
3#[derive(thiserror::Error, Debug, Clone)]
4pub enum CborError {
5    /// The CBOR was malformed and could not be parsed correctly
6    #[error("Invalid cbor: {0}")]
7    MalformedCbor(String),
8
9    /// Certificate delegation canister range was not correctly CBOR encoded
10    #[error("Invalid cbor canister ranges")]
11    MalformedCborCanisterRanges,
12
13    /// The Cbor parser expected a node of a certain type but found a different type
14    #[error("Expected node with to have type {expected_type:?}, found {found_type:?}")]
15    UnexpectedCborNodeType {
16        /// The expected type of the node
17        expected_type: String,
18        /// The actual type of the node
19        found_type: String,
20    },
21
22    /// Error converting UTF-8 string
23    #[error("Error converting UTF8 string bytes: {0}")]
24    Utf8ConversionError(#[from] std::string::FromUtf8Error),
25
26    /// The certificate was malformed and could not be parsed correctly
27    #[error(r#"Failed to parse certificate: "{0}""#)]
28    MalformedCertificate(String),
29
30    /// The hash tree was malformed and could not be parsed correctly
31    #[error(r#"Failed to parse hash tree: "{0}""#)]
32    MalformedHashTree(String),
33
34    /// The hash tree pruned data was not the correct length
35    #[error(r#"Invalid pruned data: "{0}""#)]
36    IncorrectPrunedDataLength(#[from] std::array::TryFromSliceError),
37
38    #[error("UnexpectedEndOfInput")]
39    UnexpectedEndOfInput,
40}