vc-runtime 0.1.0

Runtime backend for Visual Compiler
Documentation
//! Configuration validation errors.

use thiserror::Error;

/// Top-level configuration error.
///
/// # Future Extension
/// `Multiple` is reserved for future error accumulation.
/// Current validators are fail-fast.
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum ConfigError {
    #[error(transparent)]
    Semantic(#[from] SemanticError),

    #[error(transparent)]
    Backend(#[from] BackendValidationError),
}

/// Errors related to relationships between configuration objects.
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum SemanticError {
    #[error("unknown backend '{backend}' referenced by profile '{profile}'")]
    UnknownBackend { profile: String, backend: String },

    #[error("backend '{backend}' is disabled")]
    DisabledBackend { backend: String },
}

/// Backend-specific deterministic validation errors.
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum BackendValidationError {
    #[error("backend '{backend}' has timeout_secs = 0, must be > 0")]
    ZeroTimeout { backend: String },

    #[error("backend '{backend}' has poll_timeout_secs = 0, must be > 0")]
    ZeroPollTimeout { backend: String },

    #[error("backend '{backend}' has poll_interval_ms = 0, must be > 0")]
    ZeroPollInterval { backend: String },

    #[error("backend '{backend}' has unsupported URL scheme '{scheme}' (must be http or https)")]
    UnsupportedScheme { backend: String, scheme: String },
}