-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom error types for all errors generated in the library. Signed-off-by: José Guilherme Vanz <[email protected]>
- Loading branch information
Showing
19 changed files
with
440 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use thiserror::Error; | ||
|
||
pub type FetcherResult<T> = std::result::Result<T, FetcherError>; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum FetcherError { | ||
#[error("cannot retrieve path from uri: {0}")] | ||
InvalidFilePathError(String), | ||
#[error("invalid wasm file")] | ||
InvalidWasmFileError, | ||
#[error("wasm module cannot be save to {0:?}: {1}")] | ||
CannotWriteWasmModuleFile(String, #[source] std::io::Error), | ||
#[error(transparent)] | ||
PolicyError(#[from] crate::policy::DigestError), | ||
#[error(transparent)] | ||
VerifyError(#[from] crate::verify::errors::VerifyError), | ||
#[error(transparent)] | ||
RegistryError(#[from] crate::registry::errors::RegistryError), | ||
#[error(transparent)] | ||
UrlParserError(#[from] url::ParseError), | ||
#[error(transparent)] | ||
SourceError(#[from] crate::sources::SourceError), | ||
#[error(transparent)] | ||
StoreError(#[from] crate::store::errors::StoreError), | ||
#[error(transparent)] | ||
InvalidURLError(#[from] InvalidURLError), | ||
#[error(transparent)] | ||
CannotCreateStoragePathError(#[from] CannotCreateStoragePathError), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
#[error("{0}")] | ||
pub struct FailedToParseYamlDataError(#[from] pub serde_yaml::Error); | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
#[error("invalid URL: {0}")] | ||
pub struct CannotCreateStoragePathError(#[from] pub std::io::Error); | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
#[error("invalid URL: {0}")] | ||
pub struct InvalidURLError(pub String); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use thiserror::Error; | ||
|
||
use crate::errors::InvalidURLError; | ||
|
||
pub type RegistryResult<T> = std::result::Result<T, RegistryError>; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum RegistryError { | ||
#[error("Fail to interact with OCI registry: {0}")] | ||
OCIRegistryError(#[from] oci_distribution::errors::OciDistributionError), | ||
#[error("Invalid OCI image reference: {0}")] | ||
InvalidOCIImageReferenceError(#[from] oci_distribution::ParseError), | ||
#[error("{0}")] | ||
BuildImmutableReferenceError(String), | ||
#[error("Invalid destination format")] | ||
InvalidDestinationError, | ||
#[error("{0}")] | ||
OtherError(String), | ||
#[error(transparent)] | ||
UrlParserError(#[from] url::ParseError), | ||
#[error(transparent)] | ||
InvalidURLError(#[from] InvalidURLError), | ||
} |
Oops, something went wrong.