-
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
15 changed files
with
265 additions
and
172 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,69 @@ | ||
use thiserror::Error; | ||
|
||
pub type Result<T> = std::result::Result<T, FetcherErrors>; | ||
|
||
#[derive(Error, Debug)] | ||
pub enum FetcherErrors { | ||
#[error("{msg}: {source}")] | ||
LoadCertificateError { | ||
msg: String, | ||
#[source] | ||
source: reqwest::Error, | ||
}, | ||
#[error("certificate {0} is not in PEM nor in DER encoding")] | ||
LoadRawCertificateError(String), | ||
#[error(transparent)] | ||
UrlParserError(#[from] url::ParseError), | ||
#[error("{0}")] | ||
GithubUrlParserError(String), | ||
#[error("invalid URL: {0}")] | ||
InvalidURLError(String), | ||
#[error("cannot retrieve path from uri: {0}")] | ||
InvalidFilePathError(String), | ||
#[error("invalid destination: {0}")] | ||
InvalidDestinationError(String), | ||
#[error("unknown scheme: {0}")] | ||
UnknownSchemeError(String), | ||
#[error("invalid wasm file")] | ||
InvalidWasmFileError, | ||
#[error("Not a valid configuration file: {0}")] | ||
InvalidVerifyFileError(#[source] serde_yaml::Error), | ||
#[error("{0}")] | ||
InvalidVerifyFileConfigurationError(String), | ||
#[error("multiple policies found with the same prefix: {0}")] | ||
MultiplePoliciesFoundError(String), | ||
#[error("{0}")] | ||
BuildImmutableReferenceError(String), | ||
#[error("{0}")] | ||
ChecksumVerificationError(String), | ||
#[error("{0}")] | ||
ImageVerificationError(String), | ||
#[error("Verification only works with OCI images: Not a valid oci image: {0}")] | ||
InvalidOCIImageReferenceError(#[from] oci_distribution::ParseError), | ||
#[error("Fail to interact with OCI registry: {0}")] | ||
OCIRegistryError(#[from] oci_distribution::errors::OciDistributionError), | ||
#[error("could not pull policy {0}: empty layers")] | ||
EmptyLayersError(String), | ||
#[error("Policy cannot be verified, local wasm file doesn't exist: {0}")] | ||
MissingWasmFileError(String), | ||
#[error("Cannot read certificate from file: {0}")] | ||
CannotReadCertificateError(#[from] std::io::Error), | ||
#[error("wasm module cannot be save to {0:?}: {1}")] | ||
CannotWriteWasmModuleFile(String, #[source] std::io::Error), | ||
#[error("cannot create public key: {0} ")] | ||
CannotCreatePublicKeyError(#[source] sigstore::errors::SigstoreError), | ||
#[error("could not build a cosign client: {0} ")] | ||
CannotBuildCosignClientError(#[source] sigstore::errors::SigstoreError), | ||
#[error(transparent)] | ||
PolicyStoragePathError(#[from] std::path::StripPrefixError), | ||
#[error("failed to get image trusted layers: {0}")] | ||
FailedToFetchTrustedLayersError(#[from] sigstore::errors::SigstoreError), | ||
#[error("failed to create the http client: {0}")] | ||
FailedToCreateHttpClientError(#[from] reqwest::Error), | ||
#[error(transparent)] | ||
FailedToParseYamlDataError(#[from] serde_yaml::Error), | ||
#[error("cannot read policy in local storage: {0}")] | ||
FailedToReadPolicyInLocalStorageError(#[from] walkdir::Error), | ||
#[error("{0}")] | ||
OtherError(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
Oops, something went wrong.