Skip to main content

systemprompt_models/config/
paths.rs

1//! Path error types for configuration.
2
3#[derive(Debug, Clone)]
4pub struct PathNotConfiguredError {
5    pub path_name: String,
6    pub profile_path: Option<String>,
7}
8
9impl PathNotConfiguredError {
10    pub fn new(path_name: impl Into<String>) -> Self {
11        use crate::profile_bootstrap::ProfileBootstrap;
12        Self {
13            path_name: path_name.into(),
14            profile_path: ProfileBootstrap::get_path().ok().map(ToString::to_string),
15        }
16    }
17}
18
19impl std::fmt::Display for PathNotConfiguredError {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        writeln!(f, "Profile Error: Required path not configured\n")?;
22        writeln!(f, "  Field: paths.{}", self.path_name)?;
23        if let Some(ref profile) = self.profile_path {
24            writeln!(f, "  Profile: {}", profile)?;
25        }
26        writeln!(f, "\n  To fix:")?;
27        writeln!(
28            f,
29            "  - Run 'systemprompt cloud config' to regenerate profile"
30        )?;
31        write!(
32            f,
33            "  - Or manually add paths.{} to your profile",
34            self.path_name
35        )
36    }
37}
38
39impl std::error::Error for PathNotConfiguredError {}