Skip to main content

camel_component_exec/
error.rs

1//! ExecError — typed errors for the exec component.
2//!
3//! Pre/during-spawn failures (no output to carry) are `Err`. Post-spawn
4//! conditions with output (timeout, exit-code mismatch) are NON-error outcomes
5//! (producer returns Ok with result + headers). See spec §Error handling.
6
7/// Errors raised by the exec producer. All surface as
8/// `CamelError::ProcessorErrorWithSource(msg, Arc<ExecError>)`.
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum ExecError {
12    #[error("executable/profile not allowlisted (fail-closed): {requested:?}")]
13    NotAllowlisted { requested: String },
14
15    #[error("arg policy denied {arg:?}: {reason}")]
16    ArgPolicyDenied { arg: String, reason: String },
17
18    #[error("shell executable rejected without allow_shell: {executable:?}")]
19    ShellRejected { executable: String },
20
21    #[error("working dir escapes workspace root: {path:?}")]
22    InvalidWorkDir { path: String },
23
24    #[error("stdin exceeds cap ({size} > {max} bytes)")]
25    StdinTooLarge { size: usize, max: usize },
26
27    #[error("malformed CamelExecArgs header: {0}")]
28    InvalidArgs(String),
29
30    #[error("spawn failed: {0}")]
31    Spawn(#[from] std::io::Error),
32}