systemprompt_models/profile/
error.rs1use 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 write profile {path}: {source}")]
18 WriteFile {
19 path: PathBuf,
20 #[source]
21 source: std::io::Error,
22 },
23
24 #[error("Failed to parse profile {path}: {source}")]
25 ParseYaml {
26 path: PathBuf,
27 #[source]
28 source: serde_yaml::Error,
29 },
30
31 #[error("Failed to serialize profile: {0}")]
32 SerializeYaml(#[source] serde_yaml::Error),
33
34 #[error("Invalid profile path: {path}")]
35 InvalidProfilePath { path: PathBuf },
36
37 #[error(transparent)]
38 Gateway(#[from] GatewayProfileError),
39
40 #[error("Profile '{name}' validation failed:\n - {}", errors.join("\n - "))]
41 Validation { name: String, errors: Vec<String> },
42
43 #[error("Missing required environment variable: {name}")]
44 MissingEnvVar { name: &'static str },
45
46 #[error("Invalid environment variable {name}: {message}")]
47 InvalidEnvVar { name: &'static str, message: String },
48}