use core::fmt;
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct Error {
pub cause: String,
pub message: String,
pub response: u16,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{} (code {}): {}",
self.cause, self.response, self.message,
)
}
}
impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let json = serde_json::to_string_pretty(self).map_err(|_| fmt::Error)?;
f.write_str(&json)
}
}
impl std::error::Error for Error {}