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 in the response `platforms` object")]
44 TargetNotFound(String),
45 #[error(
47 "None of the fallback platforms `{0:?}` were found in the response `platforms` object"
48 )]
49 TargetsNotFound(Vec<String>),
50 #[error("`{0}`")]
52 Network(String),
53 #[error(transparent)]
55 Minisign(#[from] minisign_verify::Error),
56 #[error(transparent)]
58 Base64(#[from] base64::DecodeError),
59 #[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.")]
61 SignatureUtf8(String),
62 #[cfg(all(target_os = "windows", feature = "zip"))]
63 #[error(transparent)]
65 Extract(#[from] zip::result::ZipError),
66 #[error("temp directory is not on the same mount point as the AppImage")]
68 TempDirNotOnSameMountPoint,
69 #[error("binary for the current target not found in the archive")]
70 BinaryNotFoundInArchive,
71 #[error("failed to create temporary directory")]
72 TempDirNotFound,
73 #[error("Authentication failed or was cancelled")]
74 AuthenticationFailed,
75 #[error("Failed to install .deb package")]
76 DebInstallFailed,
77 #[error("Failed to install package")]
78 PackageInstallFailed,
79 #[error("invalid updater binary format")]
80 InvalidUpdaterFormat,
81 #[error(transparent)]
82 Http(#[from] http::Error),
83 #[error(transparent)]
84 InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
85 #[error(transparent)]
86 InvalidHeaderName(#[from] http::header::InvalidHeaderName),
87 #[error("Failed to format date")]
88 FormatDate,
89 #[error("The configured updater endpoint must use a secure protocol like `https`.")]
91 InsecureTransportProtocol,
92 #[error(transparent)]
93 Tauri(#[from] tauri::Error),
94}
95
96impl Serialize for Error {
97 fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
98 where
99 S: Serializer,
100 {
101 serializer.serialize_str(self.to_string().as_ref())
102 }
103}
104
105pub type Result<T> = std::result::Result<T, Error>;