drop thiserror

This commit is contained in:
Robin Appelman 2025-05-22 17:11:21 +02:00
commit c7439f746d
3 changed files with 19 additions and 66 deletions

View file

@ -1,16 +1,30 @@
use std::borrow::Cow;
use std::env::var;
use std::error::Error;
use std::fmt::Display;
use std::fs::read_to_string;
use thiserror::Error;
#[derive(Debug, Error)]
#[derive(Debug)]
pub enum SecretError {
#[error("failed to load token from {path}: {error:#}")]
Load { path: String, error: std::io::Error },
#[error("environment variable {0} referenced but not set")]
MissingEnvVar(String),
}
impl Display for SecretError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
SecretError::Load { path, error } => {
write!(f, "failed to load token from {path}: {error:#}")
}
SecretError::MissingEnvVar(var) => {
write!(f, "environment variable {var} referenced but not set")
}
}
}
}
impl Error for SecretError {}
/// Load a secret from the provided path
///
/// If the provided path includes the `$CREDENTIALS_DIRECTORY` placeholder, it will be replaced with the