systemprompt_cloud/credentials_bootstrap/
error.rs1use crate::error::CloudError;
5
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum CredentialsBootstrapError {
9 #[error("Credentials not initialized")]
10 NotInitialized,
11
12 #[error("Credentials already initialized")]
13 AlreadyInitialized,
14
15 #[error("Cloud credentials not available")]
16 NotAvailable,
17
18 #[error("Cloud credentials file not found: {path}")]
19 FileNotFound { path: String },
20
21 #[error("Cloud credentials file invalid: {message}")]
22 InvalidCredentials { message: String },
23
24 #[error("Cloud token has expired. Run 'systemprompt cloud login' to refresh")]
25 TokenExpired,
26
27 #[error("Cloud API validation failed: {message}")]
28 ApiValidationFailed { message: String },
29}
30
31impl From<CredentialsBootstrapError> for CloudError {
32 fn from(value: CredentialsBootstrapError) -> Self {
33 match value {
34 CredentialsBootstrapError::NotInitialized => Self::CredentialsNotInitialized,
35 CredentialsBootstrapError::AlreadyInitialized => Self::CredentialsAlreadyInitialized,
36 CredentialsBootstrapError::NotAvailable => Self::NotAuthenticated,
37 CredentialsBootstrapError::FileNotFound { path } => {
38 Self::CredentialsFileNotFound { path }
39 },
40 CredentialsBootstrapError::InvalidCredentials { message } => {
41 Self::InvalidCredentials { message }
42 },
43 CredentialsBootstrapError::TokenExpired => Self::TokenExpired,
44 CredentialsBootstrapError::ApiValidationFailed { message } => {
45 Self::ApiValidationFailed { message }
46 },
47 }
48 }
49}