use std::{error::Error, path::PathBuf};
use super::ClientConfigurationBuilderError;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum LoadError {
#[error("Failed to load settings: {0}")]
Load(Box<dyn Error + Send + Sync + 'static>),
#[error("Failed to load value from the environment variable {variable_name}: {message}")]
EnvVar {
variable_name: String,
message: String,
},
#[error("Failed to load file from path {path:?}: {message}")]
Path {
path: PathBuf,
message: String,
},
#[error("Failed to build the ClientConfiguration: {0}")]
Build(#[from] ClientConfigurationBuilderError),
#[error("Expected profile {0} in settings.profiles but it does not exist")]
ProfileNotFound(String),
#[error("Expected auth server {0} in settings.auth_servers but it does not exist")]
AuthServerNotFound(String),
#[cfg(feature = "tracing-config")]
#[error("Could not parse tracing filter: {0}")]
TracingFilterParseError(#[from] crate::tracing_configuration::TracingFilterError),
}
impl<E: Error + 'static> From<shellexpand::LookupError<E>> for LoadError {
fn from(value: shellexpand::LookupError<E>) -> Self {
Self::EnvVar {
variable_name: value.var_name,
message: value.cause.to_string(),
}
}
}
impl From<figment::Error> for LoadError {
fn from(value: figment::Error) -> Self {
Self::Load(Box::new(value))
}
}
#[derive(Debug, thiserror::Error)]
pub enum TokenError {
#[error("No refresh token is configured within the selected QCS credential.")]
NoRefreshToken,
#[error("No auth server is configured within the selected QCS credential.")]
NoAuthServer,
#[error("Error fetching new token from the QCS API: {0}")]
Fetch(#[from] reqwest::Error),
}