Deserialization and error handling improvements
This commit is contained in:
12
src/error.rs
12
src/error.rs
@@ -1,5 +1,7 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use crate::types;
|
||||
|
||||
pub type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -8,6 +10,7 @@ pub enum Error {
|
||||
HttpClient(reqwest::Error),
|
||||
Token(gcp_auth::Error),
|
||||
Serde(serde_json::Error),
|
||||
VertexError(types::Error),
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
@@ -17,6 +20,9 @@ impl Display for Error {
|
||||
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),
|
||||
Error::VertexError(e) => {
|
||||
write!(f, "Vertex error: {}", serde_json::to_string(e).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,3 +52,9 @@ impl From<serde_json::Error> for Error {
|
||||
Error::Serde(e)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<types::Error> for Error {
|
||||
fn from(e: types::Error) -> Self {
|
||||
Error::VertexError(e)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user