use std::path::PathBuf;
use thiserror::Error;
#[non_exhaustive]
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error("Unable to determine target-architecture")]
Architecture,
#[error("Unable to determine target-os")]
Os,
#[error("Unable to determine target-environment")]
Environment,
#[error("I/O Error ({0}): {1}")]
IoWithPath(PathBuf, std::io::Error),
#[error("Failed to copy file from {0} to {1}: {2}")]
CopyFile(PathBuf, PathBuf, std::io::Error),
#[error("Failed to rename file from {0} to {1}: {2}")]
RenameFile(PathBuf, PathBuf, std::io::Error),
#[error("Failed to symlink file from {0} to {1}: {2}")]
Symlink(PathBuf, PathBuf, std::io::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Hex(#[from] hex::FromHexError),
#[error("Hash mismatch of downloaded file")]
HashError,
#[error(transparent)]
ZipError(#[from] zip::result::ZipError),
#[error(transparent)]
DownloadError(#[from] Box<ureq::Error>),
#[error("Unsupported OS bitness")]
UnsupportedBitness,
#[error("SignTool not found")]
SignToolNotFound,
#[error("Unexpected target triple: {0}")]
UnexpectedTargetTriple(String),
#[error("Unsupported architecture for \"{0}\" target triple: {0}")]
UnsupportedArch(String, String),
#[error("Could not find the main binary in list of provided binaries")]
MainBinaryNotFound,
#[error(transparent)]
Semver(#[from] semver::Error),
#[error("Optional build metadata in app version must be numeric-only {}", .0.clone().unwrap_or_default())]
NonNumericBuildMetadata(Option<String>),
#[error("Invalid app version: {0}")]
InvalidAppVersion(String),
#[error(transparent)]
HandleBarsRenderError(#[from] handlebars::RenderError),
#[error(transparent)]
HandleBarsTemplateError(#[from] Box<handlebars::TemplateError>),
#[error("Error running makensis.exe: {0}")]
NsisFailed(std::io::Error),
#[error("Error running {0}: {0}")]
WixFailed(String, std::io::Error),
#[error("Error running create-dmg script: {0}")]
CreateDmgFailed(std::io::Error),
#[error("Error running signtool.exe: {0}")]
SignToolFailed(std::io::Error),
#[error("Error running custom signing command: {0}")]
CustomSignCommandFailed(std::io::Error),
#[error("Error running bundle_appimage.sh script: {0}")]
AppImageScriptFailed(std::io::Error),
#[error("Failed to get parent directory of {0}")]
ParentDirNotFound(PathBuf),
#[error("{0} `{1}` failed: {2}")]
HookCommandFailure(String, String, std::io::Error),
#[error("{0} `{1}` failed with exit code {2}")]
HookCommandFailureWithExitCode(String, String, i32),
#[cfg(windows)]
#[error(transparent)]
RegexError(#[from] regex::Error),
#[error(transparent)]
GlobPatternError(#[from] glob::PatternError),
#[error(transparent)]
Glob(#[from] glob::GlobError),
#[cfg(windows)]
#[error("Wix language {0} not found. It must be one of {1}")]
UnsupportedWixLanguage(String, String),
#[error(transparent)]
ImageError(#[from] image::ImageError),
#[error(transparent)]
WalkDirError(#[from] walkdir::Error),
#[error(transparent)]
StripPrefixError(#[from] std::path::StripPrefixError),
#[error(transparent)]
RelativeToError(#[from] relative_path::RelativeToError),
#[error("`{0}`")]
TimeError(#[from] time::error::Error),
#[error(transparent)]
Plist(#[from] plist::Error),
#[error("Framework {0} not found")]
FrameworkNotFound(String),
#[error("Invalid framework {framework}: {reason}")]
InvalidFramework {
framework: String,
reason: &'static str,
},
#[error("Could not find a valid icon")]
InvalidIconList,
#[error("Failed to notarize app")]
FailedToNotarize,
#[error("Failed to notarize app: {0}")]
NotarizeRejected(String),
#[error("Failed to parse notarytool output as JSON: `{0}`")]
FailedToParseNotarytoolOutput(String),
#[error("Could not find API key file. Please set the APPLE_API_KEY_PATH environment variables to the path to the {filename} file")]
ApiKeyMissing {
filename: String,
},
#[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")]
MissingNotarizeAuthVars,
#[error("Failed to list keychains: {0}")]
FailedToListKeyChain(std::io::Error),
#[error("Failed to decode certficate as base64: {0}")]
FailedToDecodeCert(std::io::Error),
#[error("Failed to create keychain: {0}")]
FailedToCreateKeyChain(std::io::Error),
#[error("Failed to unlock keychain: {0}")]
FailedToUnlockKeyChain(std::io::Error),
#[error("Failed to import certificate: {0}")]
FailedToImportCert(std::io::Error),
#[error("Failed to set keychain settings: {0}")]
FailedToSetKeychainSettings(std::io::Error),
#[error("Failed to set key partition list: {0}")]
FailedToSetKeyPartitionList(std::io::Error),
#[error("Failed to run codesign utility: {0}")]
FailedToRunCodesign(std::io::Error),
#[error("Failed to run ditto utility: {0}")]
FailedToRunDitto(std::io::Error),
#[error("Failed to run xcrun utility: {0}")]
FailedToRunXcrun(std::io::Error),
#[error("{0} already exists")]
AlreadyExists(PathBuf),
#[error("{0} does not exist")]
DoesNotExist(PathBuf),
#[error("{0} is not a directory")]
IsNotDirectory(PathBuf),
#[error("Could not find a square icon to use as AppImage icon")]
AppImageSquareIcon,
#[error(transparent)]
Base64DecodeError(#[from] base64::DecodeError),
#[error(transparent)]
Utf8Error(#[from] std::str::Utf8Error),
#[error(transparent)]
Minisign(#[from] minisign::PError),
#[error(transparent)]
SystemTimeError(#[from] std::time::SystemTimeError),
#[error("aborted key generation, {0} already exists and force overrwite wasnot desired.")]
SigningKeyExists(PathBuf),
#[error("Failed to extract filename from {0}")]
FailedToExtractFilename(PathBuf),
#[error("Failed to remove extended attributes from app bundle: {0}")]
#[cfg(target_os = "macos")]
FailedToRemoveExtendedAttributes(std::io::Error),
#[error("Embedded provision profile file {0} not found")]
EmbeddedProvisionprofileFileNotFound(PathBuf),
#[error("Could not copy embedded provision profile file {0}: {1}")]
FailedToCopyEmbeddedProvisionprofile(PathBuf, std::io::Error),
#[error("failed to open registry {0}")]
OpenRegistry(String),
#[error("failed to get {0} value on registry")]
GetRegistryValue(String),
#[error("failed to enumerate registry keys")]
FailedToEnumerateRegKeys,
}
pub type Result<T> = std::result::Result<T, Error>;