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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use cid::Error as CidError;
use encoding::Error as EncodingError;
use std::error::Error as StdError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("index {0} out of range for the amt")]
OutOfRange(usize),
#[error("failed to load AMT: height out of bounds: {0} > {1}")]
MaxHeight(usize, usize),
#[error(transparent)]
Cid(#[from] CidError),
#[error("Tried to serialize without saving cache, run flush() on Amt before serializing")]
Cached,
#[error("Vector length does not match bitmap")]
InvalidVecLength,
#[error("Serialized node cannot contain both links and values")]
LinksAndValues,
#[error("Cid ({0}) did not match any in database")]
CidNotFound(String),
#[error("{0}")]
Dynamic(Box<dyn StdError>),
#[error("{0}")]
Other(String),
}
impl From<EncodingError> for Error {
fn from(e: EncodingError) -> Self {
Self::Dynamic(Box::new(e))
}
}
impl From<Box<dyn StdError>> for Error {
fn from(e: Box<dyn StdError>) -> Self {
Self::Dynamic(e)
}
}