camel_template/error.rs
1use camel_api::CamelError;
2
3/// Errors raised by the external template component during acquisition,
4/// compilation, reload, and the resolve-time validation of operator-supplied
5/// resource limits.
6///
7/// All variants carry enough context to drive operator-visible logging while
8/// staying `Clone` so the error can be moved into a `BoxProcessor` response
9/// (`CamelError: Clone`) without consuming the original.
10#[derive(Debug, Clone, thiserror::Error)]
11pub enum TemplateReloadError {
12 #[error("template acquisition failed: {0}")]
13 Acquire(String),
14
15 #[error("template compilation failed: {0}")]
16 Compile(String),
17
18 #[error("template path escapes configured root: {0}")]
19 PathEscape(String),
20
21 #[error("template dependency cycle detected: {0}")]
22 Cycle(String),
23
24 #[error("duplicate template identity in dependency closure: {0}")]
25 DuplicateIdentity(String),
26
27 /// A limit field was set to zero at resolve time. Zero is rejected because
28 /// the limits enforce fail-closed bounding; allowing zero would silently
29 /// disable the bound.
30 #[error("template bound exceeded: {0}")]
31 BoundExceeded(&'static str),
32
33 /// The reload exceeded `reload_timeout_ms`; the late build must not swap.
34 #[error("template reload exceeded reload_timeout_ms")]
35 Timeout,
36
37 /// A build tagged at a generation that has already been superseded
38 /// reached the commit step and must be rejected.
39 #[error("template build tagged with a stale generation")]
40 StaleGeneration,
41}
42
43impl From<TemplateReloadError> for CamelError {
44 fn from(err: TemplateReloadError) -> Self {
45 CamelError::TemplateReload(err.to_string())
46 }
47}