use std::error::Error;
use thiserror::Error;
pub fn format_sdk_error(e: &dyn Error) -> String {
let mut msg = e.to_string();
let mut source = e.source();
while let Some(cause) = source {
msg.push_str(": ");
msg.push_str(&cause.to_string());
source = cause.source();
}
msg
}
#[derive(Debug, Error)]
pub enum SecParError {
#[error("Secret/Parameter Not Found: {0}")]
NotFound(String),
#[error("Failed to create secret/parameter: {0}")]
CreateFail(String),
#[error("AWS SDK error: {0}")]
AwsSdk(String),
#[error("Missing value: {0}")]
MissingValue(String),
#[error("Failed to parse spec file")]
InvalidSpec(#[from] ParseFileError),
#[error("Interactive prompt error: {0}")]
Interactive(String),
#[error("Invalid spec entry '{entry}': {reason}")]
InvalidEntry { entry: String, reason: String },
}
#[derive(Debug, Error)]
pub enum ParseFileError {
#[error("Path: `{0}`")]
NoSuchFile(String, #[source] std::io::Error),
#[error("Path: `{0}`")]
DeserializeError(String, #[source] serde_norway::Error),
}