Skip to main content

manta_shared/common/
error.rs

1//! Structured error type returned by `manta-shared`'s pure helpers.
2//!
3//! Replaces the previous use of `manta_backend_dispatcher::error::Error`
4//! in audit / jwt / kafka / config / sat-file / network-probe helpers,
5//! so that this crate (and therefore `manta-cli`) no longer needs to
6//! reach into backend-dispatcher types for its error surface.
7//!
8//! Server-side code keeps returning `manta_backend_dispatcher::error::Error`
9//! and uses `?` to convert `MantaError` at the call site via the
10//! `From<MantaError> for BackendError` impl in
11//! `crates/manta-server/src/wire_conv.rs`.
12
13use thiserror::Error;
14
15/// Errors returned by `manta-shared`'s pure helpers.
16#[derive(Error, Debug)]
17pub enum MantaError {
18  #[error("IO error: {0}")]
19  IoError(#[from] std::io::Error),
20  #[error("Config error: {0}")]
21  ConfigError(#[from] config::ConfigError),
22  #[error("TOML edit error: {0}")]
23  TomlEditError(#[from] toml_edit::TomlError),
24  #[error("Serde error: {0}")]
25  SerdeError(#[from] serde_json::Error),
26  #[error("Network error: {0}")]
27  NetError(#[from] reqwest::Error),
28  #[error("YAML error: {0}")]
29  YamlError(#[from] serde_yaml::Error),
30
31  #[error("Not found: {0}")]
32  NotFound(String),
33  #[error("Missing field: {0}")]
34  MissingField(String),
35  #[error("JWT malformed: {0}")]
36  JwtMalformed(String),
37  #[error("Kafka error: {0}")]
38  KafkaError(String),
39  #[error("Invalid pattern: {0}")]
40  InvalidPattern(String),
41  #[error("Template render error: {0}")]
42  TemplateError(String),
43
44  /// Catch-all for messages that don't fit any structured variant.
45  #[error("{0}")]
46  Other(String),
47}