use std::fmt::Display; use serde::Deserialize; #[derive(Debug, Deserialize, thiserror::Error)] pub struct AuthError { error: String, error_description: Option, } impl Display for AuthError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let error = &self.error; if let Some(ref error_description) = self.error_description { writeln!(f, "authentication type '{error}' with message '{error_description:?}'") } else { writeln!(f, "authentication type '{error}'") } } }