Improves error handling

This commit is contained in:
2024-02-06 21:23:04 +00:00
parent 67c6ba878b
commit 450fe84d8b
3 changed files with 40 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ pub enum Error {
Env(std::env::VarError),
HttpClient(reqwest::Error),
Token(gcp_auth::Error),
Serde(serde_json::Error),
}
impl Display for Error {
@@ -15,6 +16,7 @@ impl Display for Error {
Error::Env(e) => write!(f, "Environment variable error: {}", e),
Error::HttpClient(e) => write!(f, "HTTP Client error: {}", e),
Error::Token(e) => write!(f, "Token error: {}", e),
Error::Serde(e) => write!(f, "Serde error: {}", e),
}
}
}
@@ -38,3 +40,9 @@ impl From<gcp_auth::Error> for Error {
Error::Token(e)
}
}
impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}