1use std::path::PathBuf;
7
8use thiserror::Error;
9
10#[non_exhaustive]
11#[derive(Error, Debug)]
12pub enum Error {
14 #[error(transparent)]
16 Json(#[from] serde_json::Error),
17 #[error("Unable to determine target-architecture")]
19 Architecture,
20 #[error("Unable to determine target-os")]
22 Os,
23 #[error("Unable to determine target-environment")]
25 Environment,
26 #[error("I/O Error ({0}): {1}")]
28 IoWithPath(PathBuf, std::io::Error),
29 #[error("Failed to copy file from {0} to {1}: {2}")]
31 CopyFile(PathBuf, PathBuf, std::io::Error),
32 #[error("Failed to rename file from {0} to {1}: {2}")]
34 RenameFile(PathBuf, PathBuf, std::io::Error),
35 #[error("Failed to symlink file from {0} to {1}: {2}")]
37 Symlink(PathBuf, PathBuf, std::io::Error),
38 #[error(transparent)]
40 Io(#[from] std::io::Error),
41 #[error(transparent)]
43 Hex(#[from] hex::FromHexError),
44 #[error("Hash mismatch of downloaded file")]
46 HashError,
47 #[error(transparent)]
49 ZipError(#[from] zip::result::ZipError),
50 #[error(transparent)]
52 DownloadError(#[from] Box<ureq::Error>),
53 #[error("Unsupported OS bitness")]
55 UnsupportedBitness,
56 #[error("SignTool not found")]
58 SignToolNotFound,
59 #[error("Unexpected target triple: {0}")]
61 UnexpectedTargetTriple(String),
62 #[error("Unsupported architecture for \"{0}\" target triple: {0}")]
64 UnsupportedArch(String, String),
65 #[error("Could not find the main binary in list of provided binaries")]
67 MainBinaryNotFound,
68 #[error(transparent)]
70 Semver(#[from] semver::Error),
71 #[error("Optional build metadata in app version must be numeric-only {}", .0.clone().unwrap_or_default())]
73 NonNumericBuildMetadata(Option<String>),
74 #[error("Invalid app version: {0}")]
76 InvalidAppVersion(String),
77 #[error(transparent)]
79 HandleBarsRenderError(#[from] handlebars::RenderError),
80 #[error(transparent)]
82 HandleBarsTemplateError(#[from] Box<handlebars::TemplateError>),
83 #[error("Error running makensis.exe: {0}")]
85 NsisFailed(std::io::Error),
86 #[error("Error running {0}: {0}")]
88 WixFailed(String, std::io::Error),
89 #[error("Error running create-dmg script: {0}")]
91 CreateDmgFailed(std::io::Error),
92 #[error("Error running signtool.exe: {0}")]
94 SignToolFailed(std::io::Error),
95 #[error("Error running custom signing command: {0}")]
97 CustomSignCommandFailed(std::io::Error),
98 #[error("Error running bundle_appimage.sh script: {0}")]
100 AppImageScriptFailed(std::io::Error),
101 #[error("Failed to get parent directory of {0}")]
103 ParentDirNotFound(PathBuf),
104 #[error("{0} `{1}` failed: {2}")]
106 HookCommandFailure(String, String, std::io::Error),
107 #[error("{0} `{1}` failed with exit code {2}")]
109 HookCommandFailureWithExitCode(String, String, i32),
110 #[cfg(windows)]
112 #[error(transparent)]
113 RegexError(#[from] regex::Error),
114 #[error(transparent)]
116 GlobPatternError(#[from] glob::PatternError),
117 #[error(transparent)]
119 Glob(#[from] glob::GlobError),
120 #[cfg(windows)]
122 #[error("Wix language {0} not found. It must be one of {1}")]
123 UnsupportedWixLanguage(String, String),
124 #[error(transparent)]
126 ImageError(#[from] image::ImageError),
127 #[error(transparent)]
129 WalkDirError(#[from] walkdir::Error),
130 #[error(transparent)]
132 StripPrefixError(#[from] std::path::StripPrefixError),
133 #[error(transparent)]
135 RelativeToError(#[from] relative_path::RelativeToError),
136 #[error("`{0}`")]
138 TimeError(#[from] time::error::Error),
139 #[error(transparent)]
141 Plist(#[from] plist::Error),
142 #[error("Framework {0} not found")]
144 FrameworkNotFound(String),
145 #[error("Invalid framework {framework}: {reason}")]
147 InvalidFramework {
148 framework: String,
150 reason: &'static str,
152 },
153 #[error("Could not find a valid icon")]
155 InvalidIconList,
156 #[error("Failed to notarize app")]
158 FailedToNotarize,
159 #[error("Failed to notarize app: {0}")]
161 NotarizeRejected(String),
162 #[error("Failed to parse notarytool output as JSON: `{0}`")]
164 FailedToParseNotarytoolOutput(String),
165 #[error("Could not find API key file. Please set the APPLE_API_KEY_PATH environment variables to the path to the {filename} file")]
167 ApiKeyMissing {
168 filename: String,
170 },
171 #[error("Could not find APPLE_ID & APPLE_PASSWORD & APPLE_TEAM_ID or APPLE_API_KEY & APPLE_API_ISSUER & APPLE_API_KEY_PATH environment variables found")]
173 MissingNotarizeAuthVars,
174 #[error("Failed to list keychains: {0}")]
176 FailedToListKeyChain(std::io::Error),
177 #[error("Failed to decode certficate as base64: {0}")]
179 FailedToDecodeCert(std::io::Error),
180 #[error("Failed to create keychain: {0}")]
182 FailedToCreateKeyChain(std::io::Error),
183 #[error("Failed to unlock keychain: {0}")]
185 FailedToUnlockKeyChain(std::io::Error),
186 #[error("Failed to import certificate: {0}")]
188 FailedToImportCert(std::io::Error),
189 #[error("Failed to set keychain settings: {0}")]
191 FailedToSetKeychainSettings(std::io::Error),
192 #[error("Failed to set key partition list: {0}")]
194 FailedToSetKeyPartitionList(std::io::Error),
195 #[error("Failed to run codesign utility: {0}")]
197 FailedToRunCodesign(std::io::Error),
198 #[error("Failed to run ditto utility: {0}")]
200 FailedToRunDitto(std::io::Error),
201 #[error("Failed to run xcrun utility: {0}")]
203 FailedToRunXcrun(std::io::Error),
204 #[error("{0} already exists")]
206 AlreadyExists(PathBuf),
207 #[error("{0} does not exist")]
209 DoesNotExist(PathBuf),
210 #[error("{0} is not a directory")]
212 IsNotDirectory(PathBuf),
213 #[error("Could not find a square icon to use as AppImage icon")]
215 AppImageSquareIcon,
216 #[error(transparent)]
218 Base64DecodeError(#[from] base64::DecodeError),
219 #[error(transparent)]
221 Utf8Error(#[from] std::str::Utf8Error),
222 #[error(transparent)]
224 Minisign(#[from] minisign::PError),
225 #[error(transparent)]
227 SystemTimeError(#[from] std::time::SystemTimeError),
228 #[error("aborted key generation, {0} already exists and force overrwite wasnot desired.")]
230 SigningKeyExists(PathBuf),
231 #[error("Failed to extract filename from {0}")]
233 FailedToExtractFilename(PathBuf),
234 #[error("Failed to remove extended attributes from app bundle: {0}")]
236 #[cfg(target_os = "macos")]
237 FailedToRemoveExtendedAttributes(std::io::Error),
238 #[error("Embedded provision profile file {0} not found")]
240 EmbeddedProvisionprofileFileNotFound(PathBuf),
241 #[error("Could not copy embedded provision profile file {0}: {1}")]
243 FailedToCopyEmbeddedProvisionprofile(PathBuf, std::io::Error),
244 #[error("failed to open registry {0}")]
246 OpenRegistry(String),
247 #[error("failed to get {0} value on registry")]
249 GetRegistryValue(String),
250 #[error("failed to enumerate registry keys")]
252 FailedToEnumerateRegKeys,
253}
254
255pub type Result<T> = std::result::Result<T, Error>;