Skip to main content

graphrt_bundle/
error.rs

1//! Errors.
2
3/// Error building, opening or verifying a bundle.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum BundleError {
7    /// The archive is not a valid zip or violates a safety limit.
8    #[error("invalid bundle archive: {0}")]
9    Archive(String),
10    /// The manifest is missing or malformed.
11    #[error("invalid bundle manifest: {0}")]
12    Manifest(String),
13    /// A file's content does not match its recorded SHA-256.
14    #[error("bundle integrity check failed: {0}")]
15    Integrity(String),
16    /// Signature missing, malformed, invalid or from an untrusted key.
17    #[error("bundle signature: {0}")]
18    Signature(String),
19    /// A workflow inside the bundle is invalid.
20    #[error("bundle workflow `{name}`: {message}")]
21    Workflow { name: String, message: String },
22    /// A file would leak a secret (inline API key, token, password...).
23    #[error("{0}")]
24    Secret(String),
25    /// Building the bundle failed (bad input file, missing workflow...).
26    #[error("bundle build: {0}")]
27    Build(String),
28    /// A bundled plugin could not be loaded.
29    #[error("bundled plugin `{plugin}`: {message}")]
30    Plugin { plugin: String, message: String },
31    /// Filesystem error.
32    #[error("{path}: {message}")]
33    Io { path: String, message: String },
34}
35
36impl BundleError {
37    pub(crate) fn io(path: &std::path::Path, e: &std::io::Error) -> Self {
38        Self::Io { path: path.display().to_string(), message: e.to_string() }
39    }
40}