Skip to main content

objectiveai_sdk/filesystem/plugins/
install_error.rs

1use reqwest::StatusCode;
2use std::path::PathBuf;
3
4/// Failures the plugin install pipeline can encounter. Shape modelled
5/// after `objectiveai-api`'s `github::Error`: split request / response
6/// / status / parse so diagnostics name what failed, plus IO variants
7/// for the local-disk side of the flow.
8///
9/// **Platform-not-supported is NOT an error.** When the current
10/// platform isn't in `Manifest.binaries`, `Client::install_plugin`
11/// returns `Ok(false)` rather than any variant here. This enum is only
12/// for things that actually went wrong.
13#[derive(thiserror::Error, Debug)]
14pub enum InstallError {
15    #[error("manifest request failed: {0}")]
16    ManifestRequest(reqwest::Error),
17    #[error("manifest fetch returned bad status {code} from {url}: {body}")]
18    ManifestBadStatus {
19        code: StatusCode,
20        url: String,
21        body: String,
22    },
23    #[error("manifest body could not be read: {0}")]
24    ManifestResponse(reqwest::Error),
25    #[error("manifest parse failed: {0}")]
26    ManifestParse(serde_path_to_error::Error<serde_json::Error>),
27    #[error("binary request failed: {0}")]
28    BinaryRequest(reqwest::Error),
29    #[error("binary fetch returned bad status {code} from {url}")]
30    BinaryBadStatus { code: StatusCode, url: String },
31    #[error("binary body could not be read: {0}")]
32    BinaryResponse(reqwest::Error),
33    #[error("failed to create plugin directory {0}: {1}")]
34    PluginDirCreate(PathBuf, std::io::Error),
35    #[error("failed to write plugin binary {0}: {1}")]
36    BinaryWrite(PathBuf, std::io::Error),
37    #[error("failed to set executable permission on {0}: {1}")]
38    Chmod(PathBuf, std::io::Error),
39    #[error("failed to serialize manifest for persistence: {0}")]
40    ManifestSerialize(serde_json::Error),
41    #[error("failed to persist manifest at {0}: {1}")]
42    ManifestPersist(PathBuf, std::io::Error),
43    #[error("viewer-zip request failed: {0}")]
44    ViewerZipRequest(reqwest::Error),
45    #[error("viewer-zip fetch returned bad status {code} from {url}")]
46    ViewerZipBadStatus { code: StatusCode, url: String },
47    #[error("viewer-zip body could not be read: {0}")]
48    ViewerZipResponse(reqwest::Error),
49    #[error("failed to extract viewer zip into {0}: {1}")]
50    ViewerZipExtract(PathBuf, String),
51    #[error("invalid header name {name:?}: {reason}")]
52    InvalidHeaderName { name: String, reason: String },
53    #[error("invalid header value for {name:?}: {reason}")]
54    InvalidHeaderValue { name: String, reason: String },
55    #[error("plugin {repository} is already installed; pass `--upgrade` to replace it")]
56    AlreadyInstalled { repository: String },
57    #[error("repository name {repository:?} is reserved and cannot be used as a plugin name")]
58    ReservedRepositoryName { repository: String },
59}