Skip to main content

release_hub/
error.rs

1/// Errors produced by release discovery, download, verification, and installation.
2#[derive(Debug, thiserror::Error)]
3#[non_exhaustive]
4pub enum Error {
5    /// GitHub API or connector error.
6    #[error(transparent)]
7    GitHub(#[from] octocrab::Error),
8    /// Filesystem or process I/O error.
9    #[error(transparent)]
10    Io(#[from] std::io::Error),
11    /// Semantic-version parsing error.
12    #[error(transparent)]
13    Semver(#[from] semver::Error),
14    /// HTTP request or response-body error.
15    #[error(transparent)]
16    Reqwest(#[from] reqwest::Error),
17    /// Minisign decode or verification error.
18    #[error(transparent)]
19    Minisign(#[from] minisign_verify::Error),
20    /// Generic HTTP protocol or header construction error.
21    #[error(transparent)]
22    Http(#[from] http::Error),
23    /// Invalid HTTP header value.
24    #[error(transparent)]
25    InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
26    /// Invalid HTTP header name.
27    #[error(transparent)]
28    InvalidHeaderName(#[from] http::header::InvalidHeaderName),
29    /// The current CPU architecture is not supported.
30    #[error(
31        "Unsupported application architecture, expected one of `x86`, `x86_64`, `arm` or `aarch64`."
32    )]
33    UnsupportedArch,
34    /// The current operating system is not supported.
35    #[error("Unsupported OS, expected one of `linux`, `darwin` or `windows`.")]
36    UnsupportedOs,
37    /// No suitable artifact could be found for the requested target.
38    #[error("Asset not found.")]
39    AssetNotFound,
40    /// The install target path could not be derived from the executable path.
41    #[error("Failed to determine updater package extract path.")]
42    FailedToDetermineExtractPath,
43    /// An update endpoint used an insecure transport protocol.
44    #[error("The configured updater endpoint must use a secure protocol like `https`.")]
45    InsecureTransportProtocol,
46    /// The requested platform key was not present in the remote release metadata.
47    #[error("the platform `{0}` was not found on the response `platforms` object")]
48    TargetNotFound(String),
49    /// A matching detached signature asset was not found for the selected artifact.
50    #[error("missing signature asset for `{0}`")]
51    MissingSignatureAsset(String),
52    /// Generic network or transport failure represented as a message.
53    #[error("`{0}`")]
54    Network(String),
55    /// Downloaded installer or archive bytes did not match the expected format.
56    #[error("invalid updater binary format")]
57    InvalidUpdaterFormat,
58    /// Temporary staging directory creation failed.
59    #[error("failed to create temporary directory")]
60    TempDirNotFound,
61    /// Windows elevation or installer execution was denied.
62    #[error("Installation failed: insufficient privileges. Please run as administrator.")]
63    InsufficientPrivileges,
64    /// Windows installer could not proceed because files are in use.
65    #[error("Installation failed: file in use. Please close the application and try again.")]
66    FileInUse,
67    /// Windows installer launch returned an execution error code.
68    #[error("Installation failed: installer execution error. Error code: {0}")]
69    InstallerExecutionFailed(i32),
70    /// Windows elevation prompt was cancelled by the user.
71    #[error("Installation cancelled: User declined administrator privileges.")]
72    UserCancelledElevation,
73    /// JSON parsing or serialization error.
74    #[error(transparent)]
75    Json(#[from] serde_json::Error),
76    /// RFC3339 or other time parsing error.
77    #[error(transparent)]
78    Time(#[from] time::error::Parse),
79    #[cfg(target_os = "macos")]
80    /// ZIP archive extraction error on macOS.
81    #[error(transparent)]
82    Zip(#[from] zip::result::ZipError),
83}
84
85/// Convenient result alias used throughout the crate.
86pub type Result<T> = std::result::Result<T, Error>;