use std::path::PathBuf;
#[derive(Debug)]
pub enum SystemDirectoryError {
UserLocalDataDirNotFound,
UserConfigDirNotFound,
BraneLocalDataDirNotFound { path: PathBuf },
BraneConfigDirNotFound { path: PathBuf },
}
impl std::fmt::Display for SystemDirectoryError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SystemDirectoryError::UserLocalDataDirNotFound => {
write!(f, "Could not find the user's local data directory for your OS (reported as {})", std::env::consts::OS)
},
SystemDirectoryError::UserConfigDirNotFound => {
write!(f, "Could not find the user's config directory for your OS (reported as {})", std::env::consts::OS)
},
SystemDirectoryError::BraneLocalDataDirNotFound { path } => write!(f, "Brane data directory '{}' not found", path.display()),
SystemDirectoryError::BraneConfigDirNotFound { path } => write!(f, "Brane config directory '{}' not found", path.display()),
}
}
}
impl std::error::Error for SystemDirectoryError {}
#[derive(Debug)]
pub enum EncodeDecodeError {
Base64DecodeError { err: base64::DecodeError },
Utf8DecodeError { err: std::string::FromUtf8Error },
JsonDecodeError { err: serde_json::Error },
}
impl std::fmt::Display for EncodeDecodeError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EncodeDecodeError::Base64DecodeError { err } => write!(f, "Could not decode string input as Base64: {err}"),
EncodeDecodeError::Utf8DecodeError { err } => write!(f, "Could not decode binary input as UTF-8: {err}"),
EncodeDecodeError::JsonDecodeError { err } => write!(f, "Could not decode string input as JSON: {err}"),
}
}
}
impl std::error::Error for EncodeDecodeError {}