tauri_plugin_updater/
error.rs1use serde::{Serialize, Serializer};
6use thiserror::Error;
7
8#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum Error {
12 #[error("Updater does not have any endpoints set.")]
14 EmptyEndpoints,
15 #[error(transparent)]
17 Io(#[from] std::io::Error),
18 #[error(transparent)]
20 Semver(#[from] semver::Error),
21 #[error(transparent)]
23 Serialization(#[from] serde_json::Error),
24 #[error("Could not fetch a valid release JSON from the remote")]
26 ReleaseNotFound,
27 #[error("Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`.")]
29 UnsupportedArch,
30 #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
32 UnsupportedOs,
33 #[error("Failed to determine updater package extract path.")]
35 FailedToDetermineExtractPath,
36 #[error(transparent)]
38 UrlParse(#[from] url::ParseError),
39 #[error(transparent)]
41 Reqwest(#[from] reqwest::Error),
42 #[error("the platform `{0}` was not found on the response `platforms` object")]
44 TargetNotFound(String),
45 #[error("`{0}`")]
47 Network(String),
48 #[error(transparent)]
50 Minisign(#[from] minisign_verify::Error),
51 #[error(transparent)]
53 Base64(#[from] base64::DecodeError),
54 #[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.")]
56 SignatureUtf8(String),
57 #[cfg(all(target_os = "windows", feature = "zip"))]
58 #[error(transparent)]
60 Extract(#[from] zip::result::ZipError),
61 #[error("temp directory is not on the same mount point as the AppImage")]
63 TempDirNotOnSameMountPoint,
64 #[error("binary for the current target not found in the archive")]
65 BinaryNotFoundInArchive,
66 #[error("failed to create temporary directory")]
67 TempDirNotFound,
68 #[error("Authentication failed or was cancelled")]
69 AuthenticationFailed,
70 #[error("Failed to install .deb package")]
71 DebInstallFailed,
72 #[error("invalid updater binary format")]
73 InvalidUpdaterFormat,
74 #[error(transparent)]
75 Http(#[from] http::Error),
76 #[error(transparent)]
77 InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
78 #[error(transparent)]
79 InvalidHeaderName(#[from] http::header::InvalidHeaderName),
80 #[error("Failed to format date")]
81 FormatDate,
82 #[error("The configured updater endpoint must use a secure protocol like `https`.")]
84 InsecureTransportProtocol,
85 #[error(transparent)]
86 Tauri(#[from] tauri::Error),
87}
88
89impl Serialize for Error {
90 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
91 where
92 S: Serializer,
93 {
94 serializer.serialize_str(self.to_string().as_ref())
95 }
96}
97
98pub type Result<T> = std::result::Result<T, Error>;