use std::fmt;
use serde_json;
#[derive(Debug)]
pub struct TocError {
message: String
}
impl TocError {
pub fn new<E: fmt::Display>(e: &E) -> Self {
Self {
message: format!("{}", e)
}
}
pub fn from_str(st: &str) -> Self {
Self {
message: format!("{}", st)
}
}
}
impl fmt::Display for TocError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", self.message)
}
}
impl From<std::io::Error> for TocError {
fn from(value: std::io::Error) -> Self {
Self::new(&value)
}
}
impl From<std::string::FromUtf8Error> for TocError {
fn from(value: std::string::FromUtf8Error) -> Self {
Self::new(&value)
}
}
impl From<chrono::format::ParseError> for TocError {
fn from(value: chrono::format::ParseError) -> Self {
Self::new(&value)
}
}
impl From<serde_json::Error> for TocError {
fn from(value: serde_json::Error) -> Self {
Self::new(&value)
}
}