systemprompt_cloud/credentials_bootstrap/
error.rs1use crate::error::CloudError;
8
9#[derive(Debug, thiserror::Error)]
10#[non_exhaustive]
11pub enum CredentialsBootstrapError {
12 #[error("Cloud credentials not available")]
13 NotAvailable,
14
15 #[error("Cloud credentials file not found: {path}")]
16 FileNotFound { path: String },
17
18 #[error("Cloud credentials file invalid: {source}")]
19 InvalidCredentials {
20 #[source]
21 source: Box<CloudError>,
22 },
23
24 #[error("Cloud token has expired. Run 'systemprompt cloud auth login' to refresh")]
25 TokenExpired,
26
27 #[error("Cloud API validation failed: {message}: {source}")]
28 ApiValidationFailed {
29 message: String,
30 #[source]
31 source: Box<CloudError>,
32 },
33}
34
35impl CredentialsBootstrapError {
36 pub const fn is_file_not_found(&self) -> bool {
37 matches!(self, Self::FileNotFound { .. })
38 }
39}
40
41impl From<CredentialsBootstrapError> for CloudError {
42 fn from(value: CredentialsBootstrapError) -> Self {
43 match value {
44 CredentialsBootstrapError::NotAvailable => Self::NotAuthenticated,
45 CredentialsBootstrapError::FileNotFound { path } => {
46 Self::CredentialsFileNotFound { path }
47 },
48 CredentialsBootstrapError::InvalidCredentials { source } => {
49 Self::InvalidCredentials { source }
50 },
51 CredentialsBootstrapError::TokenExpired => Self::TokenExpired,
52 CredentialsBootstrapError::ApiValidationFailed { message, source } => {
53 Self::ApiValidationFailed { message, source }
54 },
55 }
56 }
57}