1use thiserror::Error;
2
3#[derive(Debug, Error)]
5pub enum Error {
6 #[error("Failed to parse CAR file: {0}")]
7 Parsing(String),
8 #[error("Invalid CAR file: {0}")]
9 InvalidFile(String),
10 #[error("Io error: {0}")]
11 Io(#[from] std::io::Error),
12 #[error("Cbor encoding error: {0}")]
13 Cbor(#[from] serde_ipld_dagcbor::error::CodecError),
14 #[error("ld read too large {0}")]
15 LdReadTooLarge(usize),
16}
17
18impl From<cid::Error> for Error {
19 fn from(err: cid::Error) -> Error {
20 Error::Parsing(err.to_string())
21 }
22}
23
24impl From<cid::multihash::Error> for Error {
25 fn from(err: cid::multihash::Error) -> Error {
26 Error::Parsing(err.to_string())
27 }
28}