Skip to main content

nexo_ext_installer/
error.rs

1//! Error variants returned by the installer.
2
3/// Errors surfaced by [`crate::resolve_release`],
4/// [`crate::download_and_verify`], and the
5/// [`crate::install_plugin`] one-shot.
6#[derive(Debug, thiserror::Error)]
7pub enum InstallError {
8    /// `<owner>/<repo>[@<tag>]` coords malformed.
9    #[error("plugin coords `{got}` invalid: {reason}")]
10    CoordsInvalid {
11        /// The offending coords string.
12        got: String,
13        /// Why parsing failed.
14        reason: &'static str,
15    },
16
17    /// HTTP request failed (network, non-2xx, decode).
18    #[error("install http error: {0}")]
19    Http(String),
20
21    /// IO write to the destination tarball path failed.
22    #[error("install io error: {0}")]
23    Io(String),
24
25    /// GitHub release JSON didn't match our convention (missing
26    /// `nexo-plugin.toml` asset, malformed manifest, tag isn't
27    /// semver-shaped).
28    #[error("release `{owner}/{repo}` shape error: {reason}")]
29    ReleaseShape {
30        /// Repo owner.
31        owner: String,
32        /// Repo name.
33        reason: String,
34        /// Reason the release didn't fit the convention.
35        repo: String,
36    },
37
38    /// Release found, but no tarball asset matched the
39    /// requested target. Listing the available targets so the
40    /// operator can pick one or override `NEXO_INSTALL_TARGET`.
41    #[error(
42        "release for `{id}@{version}` has no tarball for target `{target}`. \
43         Available: {available:?}"
44    )]
45    TargetNotFound {
46        /// Plugin id (from the release's manifest asset).
47        id: String,
48        /// Resolved version (semver).
49        version: semver::Version,
50        /// Target triple the daemon requested.
51        target: String,
52        /// Tarball asset names actually present in the release.
53        available: Vec<String>,
54    },
55
56    /// `.sha256` asset's body wasn't 64 lowercase hex chars.
57    #[error(
58        "release for `{id}` `.sha256` asset body `{got}` invalid: must be \
59         exactly 64 hex chars"
60    )]
61    Sha256Invalid {
62        /// Plugin id.
63        id: String,
64        /// Body read from the .sha256 asset.
65        got: String,
66    },
67
68    /// Computed sha256 of the downloaded tarball doesn't match
69    /// the value advertised in the `.sha256` asset.
70    #[error(
71        "sha256 mismatch for `{id}`: expected `{expected}`, got `{got}`. \
72         Tarball was tampered or the .sha256 asset is stale."
73    )]
74    Sha256Mismatch {
75        /// Plugin id.
76        id: String,
77        /// SHA256 hex from the .sha256 asset.
78        expected: String,
79        /// SHA256 hex computed from the downloaded bytes.
80        got: String,
81    },
82}