summaryrefslogtreecommitdiffstats
path: root/iroh-car/src/error.rs
blob: 3579413b42410be6f15431be644334e494715a00 (plain)
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 thiserror::Error;

/// Car utility error
#[derive(Debug, Error)]
pub enum Error {
    #[error("Failed to parse CAR file: {0}")]
    Parsing(String),
    #[error("Invalid CAR file: {0}")]
    InvalidFile(String),
    #[error("Io error: {0}")]
    Io(#[from] std::io::Error),
    #[error("Cbor encoding error: {0}")]
    Cbor(#[from] ipld::error::Error),
    #[error("ld read too large {0}")]
    LdReadTooLarge(usize),
}

impl From<cid::Error> for Error {
    fn from(err: cid::Error) -> Error {
        Error::Parsing(err.to_string())
    }
}

impl From<cid::multihash::Error> for Error {
    fn from(err: cid::multihash::Error) -> Error {
        Error::Parsing(err.to_string())
    }
}