| |
| |
| |
|
|
| use serde::{Serialize, Serializer}; |
| use thiserror::Error; |
|
|
| |
| #[derive(Debug, Error)] |
| #[non_exhaustive] |
| pub enum Error { |
| |
| #[error("Updater does not have any endpoints set.")] |
| EmptyEndpoints, |
| |
| #[error(transparent)] |
| Io(#[from] std::io::Error), |
| |
| #[error(transparent)] |
| Semver(#[from] semver::Error), |
| |
| #[error(transparent)] |
| Serialization(#[from] serde_json::Error), |
| |
| #[error("Could not fetch a valid release JSON from the remote")] |
| ReleaseNotFound, |
| |
| #[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")] |
| UnsupportedArch, |
| |
| #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")] |
| UnsupportedOs, |
| |
| #[error("Failed to determine updater package extract path.")] |
| FailedToDetermineExtractPath, |
| |
| #[error(transparent)] |
| UrlParse(#[from] url::ParseError), |
| |
| #[error(transparent)] |
| Reqwest(#[from] reqwest::Error), |
| |
| #[error("the platform `{0}` was not found in the response `platforms` object")] |
| TargetNotFound(String), |
| |
| #[error( |
| "None of the fallback platforms `{0:?}` were found in the response `platforms` object" |
| )] |
| TargetsNotFound(Vec<String>), |
| |
| #[error("`{0}`")] |
| Network(String), |
| |
| #[error(transparent)] |
| Minisign(#[from] minisign_verify::Error), |
| |
| #[error(transparent)] |
| Base64(#[from] base64::DecodeError), |
| |
| #[error("The signature {0} could not be decoded, please check if it is a valid base64 string. The signature must be the contents of the `.sig` file generated by the Tauri bundler, as a string.")] |
| SignatureUtf8(String), |
| #[cfg(all(target_os = "windows", feature = "zip"))] |
| |
| #[error(transparent)] |
| Extract(#[from] zip::result::ZipError), |
| |
| #[error("temp directory is not on the same mount point as the AppImage")] |
| TempDirNotOnSameMountPoint, |
| #[error("binary for the current target not found in the archive")] |
| BinaryNotFoundInArchive, |
| #[error("failed to create temporary directory")] |
| TempDirNotFound, |
| #[error("Authentication failed or was cancelled")] |
| AuthenticationFailed, |
| #[error("Failed to install .deb package")] |
| DebInstallFailed, |
| #[error("Failed to install package")] |
| PackageInstallFailed, |
| #[error("invalid updater binary format")] |
| InvalidUpdaterFormat, |
| #[error(transparent)] |
| Http(#[from] http::Error), |
| #[error(transparent)] |
| InvalidHeaderValue(#[from] http::header::InvalidHeaderValue), |
| #[error(transparent)] |
| InvalidHeaderName(#[from] http::header::InvalidHeaderName), |
| #[error("Failed to format date")] |
| FormatDate, |
| |
| #[error("The configured updater endpoint must use a secure protocol like `https`.")] |
| InsecureTransportProtocol, |
| #[error(transparent)] |
| Tauri(#[from] tauri::Error), |
| } |
|
|
| impl Serialize for Error { |
| fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> |
| where |
| S: Serializer, |
| { |
| serializer.serialize_str(self.to_string().as_ref()) |
| } |
| } |
|
|
| pub type Result<T> = std::result::Result<T, Error>; |
|
|