wick_asset_reference/
error.rs

1use std::path::PathBuf;
2
3use thiserror::Error;
4
5/// This crate's primary Error type.
6#[derive(Error, Debug, Clone, PartialEq)]
7#[non_exhaustive]
8pub enum Error {
9  /// Location reference was not a URL or package reference
10  #[error("Could not parse {0} as a URL or reference")]
11  BadUrl(String),
12
13  /// Could not load file.
14  #[error("Could not read file {}", .0.display())]
15  LoadError(PathBuf),
16
17  /// Remote fetch failed.
18  #[error("Asset {} wasn't found locally and couldn't be pulled: {1}", .0.display())]
19  PullFailed(PathBuf, String),
20
21  /// Local path normalization failed.
22  #[error("Normalization failed for path '{0}': {1}")]
23  NormalizationFailure(String, String),
24
25  /// Could not find file or directory.
26  #[error("File or directory {} not found", .0.display())]
27  NotFound(PathBuf),
28
29  /// Could not resolve a location to a filesystem path or an OCI reference.
30  #[error("Could not resolve {0} to a filesystem location or an OCI reference")]
31  Unresolvable(String),
32
33  /// Error returned when a file path does not reside in a target directory.
34  #[error("File {} does not reside in target directory {1}", .0.display())]
35  FileEscapesRoot(PathBuf, String),
36}