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

This commit is contained in:
Lucas Fernandes Nogueira
2022-04-05 05:47:10 -07:00
committed by GitHub
parent 6839fde11d
commit ed71679368
3 changed files with 19 additions and 6 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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),