wick_package/
error.rs

1use std::path::PathBuf;
2
3/// This crate's primary Error type.
4#[derive(thiserror::Error, Debug)]
5#[non_exhaustive]
6pub enum Error {
7  /// Tried to specify a directory instead of a configuration file.
8  #[error(
9    "Can not create a Wick package from directory '{0}'. Please specify a component or application file instead."
10  )]
11  Directory(PathBuf),
12
13  /// Tried to specify a file that is not a component or app file.
14  #[error("Can not create a Wick package from {0}. Please specify a component or application file instead.")]
15  InvalidWickConfig(String),
16
17  /// Tried to add a resource file that is not in the same directory (or relative subdirectory) as the component or application file.
18  #[error("Can not create package with file outside of parent directory scope {0}.")]
19  InvalidFileLocation(String),
20
21  /// Target directory not found or not readable.
22  #[error("Target directory {0} not found or not readable.")]
23  DestinationDir(String),
24
25  /// A manifest included a reference to a file that could not be found on disk.
26  #[error("Can not find file at {0}.")]
27  NotFound(String),
28
29  /// Metadata required for this operation.
30  #[error("Must specify metadata & version when performing package actions: {0}")]
31  NoMetadata(String),
32
33  /// Failed to read downloaded package
34  #[error("Failed to read downloaded package: {0}")]
35  PackageReadFailed(String),
36
37  /// Error returned when reading a file
38  #[error("Failed to read file '{0}': {1}")]
39  ReadFile(PathBuf, #[source] std::io::Error),
40
41  /// Error returned when working with tar files
42  #[error("Failed to read file '{}': {1}", .0.display())]
43  TarFile(PathBuf, #[source] std::io::Error),
44
45  /// Error returned when working with gz files
46  #[error("Failed to read file '{0}': {1}")]
47  GzipFile(PathBuf, #[source] std::io::Error),
48
49  /// Error returned when working with gz files
50  #[error("Error in gzip: {0}")]
51  GzipFailed(#[source] std::io::Error),
52
53  /// Tried to publish a component that didn't have a name
54  #[error("Published components must be named")]
55  NoName,
56
57  /// Tried to publish a component that didn't have a version
58  #[error("Published components must have a version")]
59  NoVersion,
60
61  /// General Configuration error
62  #[error(transparent)]
63  Config(#[from] wick_config::Error),
64
65  /// Errors related to OCI push/pull
66  #[error(transparent)]
67  Oci(#[from] wick_oci_utils::Error),
68
69  /// General asset error
70  #[error(transparent)]
71  AssetReference(#[from] wick_config::AssetError),
72
73  /// Could not parse contents as JSON
74  #[error("Could not parse {0} as JSON: {1}")]
75  InvalidJson(&'static str, #[source] serde_json::Error),
76}