Skip to main content

systemprompt_models/config/
paths.rs

1//! Typed error for unconfigured path lookups.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6#[derive(Debug, Clone)]
7pub struct PathNotConfiguredError {
8    pub path_name: String,
9    pub profile_path: Option<String>,
10}
11
12impl PathNotConfiguredError {
13    pub fn new(path_name: impl Into<String>) -> Self {
14        Self {
15            path_name: path_name.into(),
16            profile_path: None,
17        }
18    }
19
20    pub fn with_profile_path(mut self, profile_path: impl Into<String>) -> Self {
21        self.profile_path = Some(profile_path.into());
22        self
23    }
24}
25
26impl std::fmt::Display for PathNotConfiguredError {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        writeln!(f, "Profile Error: Required path not configured\n")?;
29        writeln!(f, "  Field: paths.{}", self.path_name)?;
30        if let Some(ref profile) = self.profile_path {
31            writeln!(f, "  Profile: {}", profile)?;
32        }
33        writeln!(f, "\n  To fix:")?;
34        writeln!(
35            f,
36            "  - Run 'systemprompt cloud config' to regenerate profile"
37        )?;
38        write!(
39            f,
40            "  - Or manually add paths.{} to your profile",
41            self.path_name
42        )
43    }
44}
45
46impl std::error::Error for PathNotConfiguredError {}