add support for serde_json::Error behind feature flag

master
rascul 8 months ago
parent ea23831bc6
commit 4dc026bb58

@ -7,6 +7,8 @@ description = "Error wrapper that with a message"
license = "MIT"
keywords = ["error", "result"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = { version = "1.0", optional = true }
[features]
default = []

@ -56,3 +56,14 @@ impl From<Box<dyn Error>> for Rear {
}
}
}
#[cfg(feature = "serde_json")]
impl From<serde_json::Error> for Rear {
fn from(error: serde_json::Error) -> Self {
let message: String = error.to_string();
Self {
error: error.into(),
message: message,
}
}
}

Loading…
Cancel
Save