From ed71679368845f603680465fdffcc90fe842bb8c Mon Sep 17 00:00:00 2001 From: Lucas Fernandes Nogueira Date: Tue, 5 Apr 2022 05:47:10 -0700 Subject: [PATCH] refactor(updater): improve unsupported error variants, closes #3817 (#3849) --- .changes/updater-detailed-unsupported-error.md | 5 +++++ core/tauri/src/updater/core.rs | 6 +++--- core/tauri/src/updater/error.rs | 14 +++++++++++--- 3 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 .changes/updater-detailed-unsupported-error.md diff --git a/.changes/updater-detailed-unsupported-error.md b/.changes/updater-detailed-unsupported-error.md new file mode 100644 index 000000000..dc63ca16a --- /dev/null +++ b/.changes/updater-detailed-unsupported-error.md @@ -0,0 +1,5 @@ +--- +"tauri": patch +--- + +**Breaking change**: Removed the `tauri::updater::Error::UnsupportedPlatform` variant and added `UnsupportedLinuxPackage`, `UnsupportedOs` and `UnsupportedArch` for better error information. diff --git a/core/tauri/src/updater/core.rs b/core/tauri/src/updater/core.rs index 2221c000e..1a3fafcfc 100644 --- a/core/tauri/src/updater/core.rs +++ b/core/tauri/src/updater/core.rs @@ -312,8 +312,8 @@ impl UpdateBuilder { let target = self .target .or_else(|| get_updater_target().map(Into::into)) - .ok_or(Error::UnsupportedPlatform)?; - let arch = get_updater_arch().ok_or(Error::UnsupportedPlatform)?; + .ok_or(Error::UnsupportedOs)?; + let arch = get_updater_arch().ok_or(Error::UnsupportedArch)?; let json_target = if has_custom_target { target.clone() } else { @@ -498,7 +498,7 @@ impl Update { // anythin with it yet #[cfg(target_os = "linux")] if self.app.state::().appimage.is_none() { - return Err(Error::UnsupportedPlatform); + return Err(Error::UnsupportedLinuxPackage); } // set our headers diff --git a/core/tauri/src/updater/error.rs b/core/tauri/src/updater/error.rs index 46782c65a..ad6995312 100644 --- a/core/tauri/src/updater/error.rs +++ b/core/tauri/src/updater/error.rs @@ -41,9 +41,17 @@ pub enum Error { /// Error building updater. #[error("Unable to extract the new version: {0}")] Extract(String), - /// Updater is not supported for current operating system or platform. - #[error("Unsupported operating system or platform")] - UnsupportedPlatform, + /// Updater cannot be executed on this Linux package. Currently the updater is enabled only on AppImages. + #[error("Cannot run updater on this Linux package. Currently only an AppImage can be updated.")] + UnsupportedLinuxPackage, + /// Operating system is not supported. + #[error("unsupported OS, expected one of `linux`, `darwin` or `windows`.")] + UnsupportedOs, + /// Unsupported app architecture. + #[error( + "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`." + )] + UnsupportedArch, /// The platform was not found on the updater JSON response. #[error("the platform `{0}` was not found on the response `platforms` object")] TargetNotFound(String),