Skip to content

Commit

Permalink
refactor(updater): improve unsupported error variants, closes #3817 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasfernog committed Apr 5, 2022
1 parent 6839fde commit ed71679
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .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.
6 changes: 3 additions & 3 deletions core/tauri/src/updater/core.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions core/tauri/src/updater/error.rs
Expand Up @@ -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),
Expand Down

0 comments on commit ed71679

Please sign in to comment.