Skip to main content

loadsmith_core/
error.rs

1/// Errors that can occur while interacting with the structs in this crate.
2#[derive(Debug, thiserror::Error)]
3pub enum Error {
4    #[error("I/O error")]
5    Io(#[from] std::io::Error),
6
7    #[error("semver error")]
8    Semver(#[from] semver::Error),
9
10    #[error("URL parse error")]
11    Url(#[from] url::ParseError),
12
13    #[error("invalid package reference format")]
14    InvalidPackageRefFormat,
15
16    #[error("unknown checksum algorithm: {0}")]
17    UnknownAlgorithm(String),
18
19    #[error("invalid checksum format")]
20    InvalidChecksumFormat,
21
22    #[error("invalid blake3 hex value")]
23    InvalidBlake3Hex(#[source] blake3::HexError),
24
25    #[error("invalid sha256 hex value")]
26    InvalidSha256Hex(#[source] hex::FromHexError),
27}
28
29/// Convenience alias for [`std::result::Result`] with the crate-level [`Error`] type.
30pub type Result<T> = std::result::Result<T, Error>;