pub trait ErrorConverter {
type Error: std::error::Error;
fn store_origin(
error: &Self::Error,
text: Option<String>,
mut context: std::collections::BTreeMap<String, serde_value::Value>,
) -> (String, std::collections::BTreeMap<String, serde_value::Value>) {
match text {
Some(text) => {
context.insert("origin".to_string(), serde_value::Value::String(error.to_string()));
(text, context)
}
None => (error.to_string(), context),
}
}
fn convert_error(error: &Self::Error, text: Option<String>, context: std::collections::BTreeMap<String, serde_value::Value>) -> crate::Error {
let (text, context) = Self::store_origin(error, text, context);
Self::convert(error, text, context)
}
fn convert(error: &Self::Error, text: String, context: std::collections::BTreeMap<String, serde_value::Value>) -> crate::Error;
}