opencode-provider-manager 0.1.7-beta.4

TUI/CLI binary crate for managing OpenCode provider configs
Documentation
//! Error types for agent-config.

use std::path::PathBuf;

/// Result type alias for agent-config operations.
pub type Result<T> = std::result::Result<T, AgentConfigError>;

/// Errors that can occur when working with agent configurations.
#[derive(Debug, thiserror::Error)]
pub enum AgentConfigError {
    /// Failed to read a config file.
    #[error("Failed to read config file at {path}: {source}")]
    ReadError {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    /// Failed to write a config file.
    #[error("Failed to write config file at {path}: {source}")]
    WriteError {
        path: PathBuf,
        #[source]
        source: std::io::Error,
    },

    /// Failed to parse JSON.
    #[error("JSON parse error in {path}: {source}")]
    JsonParseError {
        path: PathBuf,
        #[source]
        source: serde_json::Error,
    },

    /// Failed to parse TOML.
    #[error("TOML parse error in {path}: {source}")]
    TomlParseError {
        path: PathBuf,
        #[source]
        source: Box<toml::de::Error>,
    },

    /// Failed to parse YAML.
    #[error("YAML parse error in {path}: {source}")]
    YamlParseError {
        path: PathBuf,
        #[source]
        source: Box<serde_yaml::Error>,
    },

    /// Failed to serialize config.
    #[error("Serialization error: {0}")]
    SerializeError(#[from] serde_json::Error),

    /// Validation error — config does not conform to the schema.
    #[error("Validation error: {0}")]
    ValidationError(String),

    /// Config file not found.
    #[error("Config file not found: {0}")]
    NotFound(PathBuf),

    /// Unsupported file format.
    #[error("Unsupported config format '{format}' for file {path}")]
    UnsupportedFormat { format: String, path: PathBuf },

    /// Layer is invalid or unsupported.
    #[error("Invalid config layer: {0}")]
    InvalidLayer(String),

    /// Generic I/O error.
    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    /// Other errors.
    #[error("{0}")]
    Other(String),
}