2021-04-11 01:09:09 +03:00
|
|
|
// Copyright 2019-2021 Tauri Programme within The Commons Conservancy
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2021-01-30 18:15:47 +03:00
|
|
|
use std::{io, num, path};
|
2021-04-05 20:51:17 +03:00
|
|
|
use thiserror::Error as DeriveError;
|
2020-05-30 02:56:05 +03:00
|
|
|
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Errors returned by the bundler.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[derive(Debug, DeriveError)]
|
2021-05-06 04:22:45 +03:00
|
|
|
#[non_exhaustive]
|
2020-05-30 02:56:05 +03:00
|
|
|
pub enum Error {
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Bundler error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("{0}")]
|
|
|
|
BundlerError(#[from] anyhow::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to use glob pattern.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
GlobError(#[from] glob::GlobError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Invalid glob pattern.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
GlobPatternError(#[from] glob::PatternError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// I/O error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
IoError(#[from] io::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Image error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
ImageError(#[from] image::ImageError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// TOML error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
TomlError(#[from] toml::de::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Error walking directory.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
WalkdirError(#[from] walkdir::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Strip prefix error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
StripError(#[from] path::StripPrefixError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Number parse error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
ConvertError(#[from] num::TryFromIntError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Zip error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
ZipError(#[from] zip::result::ZipError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Hex error.
|
|
|
|
#[cfg(target_os = "windows")]
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
HexError(#[from] hex::FromHexError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Handlebars template error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
HandleBarsError(#[from] handlebars::RenderError),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// JSON error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
JsonError(#[from] serde_json::error::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Regex error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
RegexError(#[from] regex::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to perform HTTP request.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[cfg(windows)]
|
|
|
|
#[error("`{0}`")]
|
|
|
|
HttpError(#[from] attohttpc::Error),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to validate downloaded file hash.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("hash mismatch of downloaded file")]
|
|
|
|
HashError,
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Unsupported architecture.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("Architecture Error: `{0}`")]
|
|
|
|
ArchError(String),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Couldn't find icons.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("Could not find Icon paths. Please make sure they exist in the tauri config JSON file")]
|
|
|
|
IconPathError,
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Error on path util operation.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("Path Error:`{0}`")]
|
|
|
|
PathUtilError(String),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Error on shell script.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("Shell Scripting Error:`{0}`")]
|
|
|
|
ShellScriptError(String),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Generic error.
|
2020-05-30 02:56:05 +03:00
|
|
|
#[error("`{0}`")]
|
|
|
|
GenericError(String),
|
2021-04-05 20:51:17 +03:00
|
|
|
/// No bundled project found for the updater.
|
|
|
|
#[error("Unable to find a bundled project for the updater")]
|
|
|
|
UnableToFindProject,
|
2021-04-30 17:39:50 +03:00
|
|
|
/// String is not UTF-8.
|
2021-03-29 01:58:44 +03:00
|
|
|
#[error("string is not UTF-8")]
|
|
|
|
Utf8(#[from] std::str::Utf8Error),
|
|
|
|
/// Windows SignTool not found.
|
|
|
|
#[error("SignTool not found")]
|
|
|
|
SignToolNotFound,
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to open Windows registry.
|
2021-03-29 01:58:44 +03:00
|
|
|
#[error("failed to open registry {0}")]
|
|
|
|
OpenRegistry(String),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to get registry value.
|
2021-03-29 01:58:44 +03:00
|
|
|
#[error("failed to get {0} value on registry")]
|
|
|
|
GetRegistryValue(String),
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Unsupported OS bitness.
|
2021-03-29 01:58:44 +03:00
|
|
|
#[error("unsupported OS bitness")]
|
|
|
|
UnsupportedBitness,
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Failed to sign application.
|
2021-03-29 01:58:44 +03:00
|
|
|
#[error("failed to sign app: {0}")]
|
|
|
|
Sign(String),
|
2020-05-30 02:56:05 +03:00
|
|
|
}
|
|
|
|
|
2021-04-30 17:39:50 +03:00
|
|
|
/// Convenient type alias of Result type.
|
2020-05-30 02:56:05 +03:00
|
|
|
pub type Result<T> = anyhow::Result<T, Error>;
|