diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2022-10-28 20:00:55 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2022-10-28 20:00:55 -0700 |
commit | f99cff96758176701656285712246173db76ac58 (patch) | |
tree | 10a4f8c167c055b39a96a342f9a9334ec877414e /iroh-car/src/error.rs | |
parent | 4b4eb3aa819ee16cd8d7074cfd21d94deab2276d (diff) | |
download | adenosine-f99cff96758176701656285712246173db76ac58.tar.gz adenosine-f99cff96758176701656285712246173db76ac58.zip |
copy in iroh-car from iroh repo, verbatim
Diffstat (limited to 'iroh-car/src/error.rs')
-rw-r--r-- | iroh-car/src/error.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/iroh-car/src/error.rs b/iroh-car/src/error.rs new file mode 100644 index 0000000..3579413 --- /dev/null +++ b/iroh-car/src/error.rs @@ -0,0 +1,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()) + } +} |