Skip to main content

systemprompt_models/profile/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4use super::GatewayProfileError;
5
6pub type ProfileResult<T> = Result<T, ProfileError>;
7
8#[derive(Debug, Error)]
9pub enum ProfileError {
10    #[error("Failed to read profile {path}: {source}")]
11    ReadFile {
12        path: PathBuf,
13        #[source]
14        source: std::io::Error,
15    },
16
17    #[error("Failed to parse profile {path}: {source}")]
18    ParseYaml {
19        path: PathBuf,
20        #[source]
21        source: serde_yaml::Error,
22    },
23
24    #[error("Failed to serialize profile: {0}")]
25    SerializeYaml(#[source] serde_yaml::Error),
26
27    #[error("Invalid profile path: {path}")]
28    InvalidProfilePath { path: PathBuf },
29
30    #[error(transparent)]
31    Gateway(#[from] GatewayProfileError),
32
33    #[error("Profile '{name}' validation failed:\n  - {}", errors.join("\n  - "))]
34    Validation { name: String, errors: Vec<String> },
35
36    #[error("Missing required environment variable: {name}")]
37    MissingEnvVar { name: &'static str },
38
39    #[error("Invalid environment variable {name}: {message}")]
40    InvalidEnvVar { name: &'static str, message: String },
41}