/
githubmirror
/
the-algorithm
Обзор
Документация
Войти
/
githubmirror
/
the-algorithm
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
navi/segdense/src/error.rs
53 строки
2 KB
twitter-team
improvements from external prs
28 апр 2023, 18:37
28 апр 2023, 18:37
31e82d6
Код
Авторство
О чём код?
use std::fmt::Display; /** * Custom error */ #[derive(Debug)] pub enum SegDenseError { IoError(std::io::Error), Json(serde_json::Error), JsonMissingRoot, JsonMissingObject, JsonMissingArray, JsonArraySize, JsonMissingInputFeature, } impl Display for SegDenseError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { SegDenseError::IoError(io_error) => write!(f, "{}", io_error), SegDenseError::Json(serde_json) => write!(f, "{}", serde_json), SegDenseError::JsonMissingRoot => { write!(f, "{}", "SegDense JSON: Root Node note found!") } SegDenseError::JsonMissingObject => { write!(f, "{}", "SegDense JSON: Object note found!") } SegDenseError::JsonMissingArray => { write!(f, "{}", "SegDense JSON: Array Node note found!") } SegDenseError::JsonArraySize => { write!(f, "{}", "SegDense JSON: Array size not as expected!") } SegDenseError::JsonMissingInputFeature => { write!(f, "{}", "SegDense JSON: Missing input feature!") } } } } impl std::error::Error for SegDenseError {} impl From<std::io::Error> for SegDenseError { fn from(err: std::io::Error) -> Self { SegDenseError::IoError(err) } } impl From<serde_json::Error> for SegDenseError { fn from(err: serde_json::Error) -> Self { SegDenseError::Json(err) } }