helm_rs/error.rs
1//! The crate error type.
2
3use std::path::PathBuf;
4
5/// Result alias using the crate [`enum@Error`].
6pub type Result<T> = std::result::Result<T, Error>;
7
8/// Everything that can go wrong when driving Helm through a backend.
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum Error {
12 /// The `helm` binary could not be found or executed.
13 #[error("helm binary not found: {}", .0.display())]
14 BinaryNotFound(PathBuf),
15
16 /// The `helm` binary is older than Helm 4.
17 #[error("unsupported helm version {found}: helm-rs requires Helm 4.0.0 or newer")]
18 UnsupportedVersion {
19 /// The version the binary reported.
20 found: semver::Version,
21 },
22
23 /// Helm reported `release: not found`; carries Helm's error message.
24 #[error("release not found: {0}")]
25 ReleaseNotFound(String),
26
27 /// Helm reported that another install, upgrade or rollback is in progress.
28 #[error("another operation is in progress: {0}")]
29 OperationInProgress(String),
30
31 /// Helm gave up waiting (context deadline or wait timeout); carries Helm's error message.
32 #[error("timed out: {0}")]
33 Timeout(String),
34
35 /// The backend failed in a way that is not classified; the raw stderr is always kept.
36 #[error("helm failed (exit code {exit_code:?}): {stderr}")]
37 Backend {
38 /// The process exit code, `None` when killed by a signal.
39 exit_code: Option<i32>,
40 /// The raw standard error of the process.
41 stderr: String,
42 },
43
44 /// The output of a command could not be parsed.
45 #[error("cannot parse the output of `{command}`: {message}")]
46 Parse {
47 /// The command whose output was unparseable.
48 command: &'static str,
49 /// What was wrong with the output.
50 message: String,
51 },
52
53 /// The command cannot be expressed to Helm as given (for example a secret that Helm only
54 /// accepts on its command line); carries the reason.
55 #[error("invalid command: {0}")]
56 InvalidCommand(String),
57
58 /// An I/O error.
59 #[error(transparent)]
60 Io(#[from] std::io::Error),
61
62 /// A JSON error.
63 #[error(transparent)]
64 Json(#[from] serde_json::Error),
65
66 /// A YAML error.
67 #[error(transparent)]
68 Yaml(#[from] serde_norway::Error),
69
70 /// A chart could not be loaded.
71 #[error(transparent)]
72 Chart(#[from] crate::chart::Error),
73
74 /// Values failed validation against a chart schema.
75 #[error(transparent)]
76 Schema(#[from] crate::schema::Error),
77
78 /// A release record could not be decoded.
79 #[error(transparent)]
80 Release(#[from] crate::release::Error),
81
82 /// A rendered manifest could not be parsed.
83 #[error(transparent)]
84 Manifest(#[from] crate::manifest::Error),
85
86 /// The backend does not handle this command (named by its type).
87 #[error("the backend does not support {0}")]
88 Unsupported(&'static str),
89}