use thiserror

This commit is contained in:
Elnu 2023-08-24 12:37:32 -07:00
parent 9009ae9e24
commit 2c72d5fc15
16 changed files with 104 additions and 163 deletions

View file

@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
svg-units = { path = "../svg-units" }
askama = "0.12.0"
derive_more = "0.99.17"
kle-serial = "0.2.2"
lazy_static = "1.4.0"
serde_json = "1.0.105"
err-derive = "0.3.1"

View file

@ -1,7 +1,7 @@
use std::path::Path;
use askama::Template;
use derive_more::From;
use err_derive::Error;
use lazy_static::lazy_static;
use svg_units::{SVGMeasure, SVGUnit};
@ -38,11 +38,14 @@ mod filters {
}
}
#[derive(From, Debug)]
#[derive(Error, Debug)]
pub enum Error {
Io(std::io::Error),
Template(askama::Error),
LayoutParse(serde_json::Error),
#[error(display = "I/O error")]
Io(#[cause] std::io::Error),
#[error(display = "Templating error")]
Template(#[cause] askama::Error),
#[error(display = "Failed to parse KLE JSON")]
LayoutParse(#[cause] serde_json::Error),
}
pub type Result<T> = std::result::Result<T, Error>;