From 9c51da97a82a72b9f23c2490a189ebe75b1c2bec Mon Sep 17 00:00:00 2001 From: endernon Date: Tue, 5 Nov 2024 20:02:20 +0000 Subject: [PATCH] print the actual json error if the config is broken --- src/errorfr/mod.rs | 2 +- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/errorfr/mod.rs b/src/errorfr/mod.rs index 718018c..81b97eb 100644 --- a/src/errorfr/mod.rs +++ b/src/errorfr/mod.rs @@ -8,7 +8,7 @@ pub enum Errorfr { ItemJsonMissing, /// item config json is corrupt - #[error("Error 2: item config json is corrupt, Reread config.md\n")] + #[error("Error 2: item config json is corrupt, Reread config.md\n{0:?}")] ItemJsonCorrupt(serde_json::Error), /// idmap is missing diff --git a/src/main.rs b/src/main.rs index 72e61fd..558d68f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,7 @@ fn cook() -> Result<(), Errorfr> { // load configs let json_config: Jsonconfig = serde_json::from_reader(fs::File::open(configpath) .map_err(|_| Errorfr::ItemJsonMissing)?) - .map_err(|_| Errorfr::ItemJsonCorrupt)?; + .map_err(|e| Errorfr::ItemJsonCorrupt(e))?; let idsmap: HashMap = serde_json::from_reader(fs::File::open("id_keys.json") .map_err(|_| Errorfr::IDMapJsonMissing)?) .map_err(|_| Errorfr::IDMapJsonCorrupt)?;