release_hub/
error.rs

1// Copyright (c) 2025 BibCiTeX Contributors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3//
4// This file contains code derived from tauri-plugin-updater
5// Original source: https://github.com/tauri-apps/plugins-workspace/tree/v2/plugins/updater
6// Copyright (c) 2015 - Present - The Tauri Programme within The Commons Conservancy.
7// Licensed under MIT OR MIT/Apache-2.0
8//! Error types for the updater.
9//!
10//! The `Error` enum captures failures that can happen when checking, downloading
11//! or installing updates across supported platforms.
12/// All errors that can occur while running the updater.
13#[derive(Debug, thiserror::Error)]
14pub enum Error {
15    /// GitHub errors.
16    #[error(transparent)]
17    GitHub(#[from] octocrab::Error),
18    /// IO errors.
19    #[error(transparent)]
20    Io(#[from] std::io::Error),
21    /// Semver errors.
22    #[error(transparent)]
23    Semver(#[from] semver::Error),
24    /// Unsupported app architecture.
25    #[error(
26        "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`."
27    )]
28    UnsupportedArch,
29    /// Operating system is not supported.
30    #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
31    UnsupportedOs,
32    /// Asset not found
33    #[error("Asset not found.")]
34    AssetNotFound,
35    /// Failed to determine updater package extract path
36    #[error("Failed to determine updater package extract path.")]
37    FailedToDetermineExtractPath,
38    /// `reqwest` crate errors.
39    #[error(transparent)]
40    Reqwest(#[from] reqwest::Error),
41    /// The platform was not found on the updater JSON response.
42    #[error("the platform `{0}` was not found on the response `platforms` object")]
43    TargetNotFound(String),
44    /// Download failed
45    #[error("`{0}`")]
46    Network(String),
47    /// Temp dir is not on same mount mount. This prevents our updater to rename the AppImage to a temp file.
48    #[error("temp directory is not on the same mount point as the AppImage")]
49    TempDirNotOnSameMountPoint,
50    #[error("failed to create temporary directory")]
51    TempDirNotFound,
52    #[error("Authentication failed or was cancelled")]
53    AuthenticationFailed,
54    #[error("invalid updater binary format")]
55    InvalidUpdaterFormat,
56    /// Windows installer execution failed due to insufficient privileges
57    #[error("Installation failed: insufficient privileges. Please run as administrator.")]
58    InsufficientPrivileges,
59    /// Windows installer execution failed due to file being in use
60    #[error("Installation failed: file in use. Please close the application and try again.")]
61    FileInUse,
62    /// Windows installer execution failed
63    #[error("Installation failed: installer execution error. Error code: {0}")]
64    InstallerExecutionFailed(i32),
65    /// User cancelled the UAC prompt
66    #[error("Installation cancelled: User declined administrator privileges.")]
67    UserCancelledElevation,
68    #[error(transparent)]
69    Http(#[from] http::Error),
70    #[error(transparent)]
71    InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
72    #[error(transparent)]
73    InvalidHeaderName(#[from] http::header::InvalidHeaderName),
74    /// The configured updater endpoint must use a secure protocol like `https`
75    #[error(transparent)]
76    URLParseError(#[from] url::ParseError),
77    /// Zip extraction errors.
78    #[cfg(target_os = "macos")]
79    #[error(transparent)]
80    Zip(#[from] zip::result::ZipError),
81}
82
83/// Convenient result alias for functions that may return [`Error`].
84pub type Result<T> = std::result::Result<T, Error>;