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
use derive_more::{Display, From};
#[derive(Debug, Display, From)]
pub enum BlockStoreError {
SqliteError(rusqlite::Error),
CidError(libipld::cid::Error),
TryFromIntError(std::num::TryFromIntError),
Other(anyhow::Error),
}
impl std::error::Error for BlockStoreError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
BlockStoreError::SqliteError(e) => Some(e),
BlockStoreError::CidError(e) => Some(e),
BlockStoreError::TryFromIntError(e) => Some(e),
BlockStoreError::Other(e) => Some(e.as_ref()),
}
}
}
pub type Result<T> = std::result::Result<T, BlockStoreError>;