kaptein_viewmodel/error.rs
1//! The unified error enum for the view-model.
2//!
3//! Raw `kube::Error` and subprocess failures are mapped here into redaction-aware,
4//! user-facing variants (see `ROADMAP.md` cross-cutting commitments).
5
6use serde::{Deserialize, Serialize};
7
8#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq, Serialize, Deserialize)]
9pub enum Error {
10 #[error("query failed: {0}")]
11 Query(String),
12
13 #[error("the store is at revision {0} and cannot serve a subscription from {1}")]
14 StaleSubscription(u64, u64),
15
16 #[error("resource not found: {0}")]
17 NotFound(String),
18
19 #[error("operation forbidden: {verb} on {resource}")]
20 Forbidden { verb: String, resource: String },
21
22 #[error("external tool failed: {0}")]
23 ExternalTool(String),
24
25 #[error("internal error: {0}")]
26 Internal(String),
27}
28
29// NOTE: the `From<kaptein_core::Error>` mapping deliberately does **not** live here.
30// `kaptein-viewmodel` must be wasm-pure (the browser UI consumes it), so it cannot
31// depend on `kaptein-core` (which pulls `kube` → `hyper` → `mio`, all non-wasm). The
32// core→viewmodel error mapping lives at the *integration layer* — the native frontend
33// or binary that owns both crates — not in the view-model.