Skip to main content

vc_runtime/config/validation/
error.rs

1//! Configuration validation errors.
2
3use thiserror::Error;
4
5/// Top-level configuration error.
6///
7/// # Future Extension
8/// `Multiple` is reserved for future error accumulation.
9/// Current validators are fail-fast.
10#[non_exhaustive]
11#[derive(Debug, Error)]
12pub enum ConfigError {
13    #[error(transparent)]
14    Semantic(#[from] SemanticError),
15
16    #[error(transparent)]
17    Backend(#[from] BackendValidationError),
18}
19
20/// Errors related to relationships between configuration objects.
21#[non_exhaustive]
22#[derive(Debug, Error)]
23pub enum SemanticError {
24    #[error("unknown backend '{backend}' referenced by profile '{profile}'")]
25    UnknownBackend { profile: String, backend: String },
26
27    #[error("backend '{backend}' is disabled")]
28    DisabledBackend { backend: String },
29}
30
31/// Backend-specific deterministic validation errors.
32#[non_exhaustive]
33#[derive(Debug, Error)]
34pub enum BackendValidationError {
35    #[error("backend '{backend}' has timeout_secs = 0, must be > 0")]
36    ZeroTimeout { backend: String },
37
38    #[error("backend '{backend}' has poll_timeout_secs = 0, must be > 0")]
39    ZeroPollTimeout { backend: String },
40
41    #[error("backend '{backend}' has poll_interval_ms = 0, must be > 0")]
42    ZeroPollInterval { backend: String },
43
44    #[error("backend '{backend}' has unsupported URL scheme '{scheme}' (must be http or https)")]
45    UnsupportedScheme { backend: String, scheme: String },
46}