From f7ea8eae099b92dc8bc482474589d53134b3dbc3 Mon Sep 17 00:00:00 2001 From: Sebastian Kuzminsky Date: Sun, 9 Feb 2025 15:23:07 -0700 Subject: [PATCH] recipe error handling --- tools/src/recipe.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/src/recipe.rs b/tools/src/recipe.rs index ddb53ad..bb77321 100644 --- a/tools/src/recipe.rs +++ b/tools/src/recipe.rs @@ -1,3 +1,11 @@ +#[derive(Debug, thiserror::Error)] +pub enum RecipeLoadError { + #[error(transparent)] + StdIoError(#[from] std::io::Error), + #[error(transparent)] + TomlDeserializeError(#[from] toml::de::Error), +} + #[derive(Clone, Copy, Debug, PartialEq, serde::Deserialize)] pub enum Unit { Foot, @@ -91,7 +99,7 @@ pub struct Recipe { } impl Recipe { - pub fn from_file(file: &std::path::PathBuf) -> anyhow::Result { + pub fn from_file(file: &std::path::PathBuf) -> Result { let recipe_contents = std::fs::read_to_string(file)?; let mut recipe: Recipe = toml::from_str(&recipe_contents)?; if recipe.outputs == None {