Pārlūkot izejas kodu

refactor(updater): improve unsupported error variants, closes #3817 (#3849)

Lucas Fernandes Nogueira 3 gadi atpakaļ
vecāks
revīzija
ed71679368

+ 5 - 0
.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.

+ 3 - 3
core/tauri/src/updater/core.rs

@@ -312,8 +312,8 @@ impl<R: Runtime> UpdateBuilder<R> {
     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<R: Runtime> Update<R> {
     // anythin with it yet
     #[cfg(target_os = "linux")]
     if self.app.state::<Env>().appimage.is_none() {
-      return Err(Error::UnsupportedPlatform);
+      return Err(Error::UnsupportedLinuxPackage);
     }
 
     // set our headers

+ 11 - 3
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),