print the actual json error if the config is broken

This commit is contained in:
endernon 2024-11-05 20:02:20 +00:00
parent 510b023e4e
commit 9c51da97a8
2 changed files with 2 additions and 2 deletions

View file

@ -8,7 +8,7 @@ pub enum Errorfr {
ItemJsonMissing, ItemJsonMissing,
/// item config json is corrupt /// 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), ItemJsonCorrupt(serde_json::Error),
/// idmap is missing /// idmap is missing

View file

@ -54,7 +54,7 @@ fn cook() -> Result<(), Errorfr> {
// load configs // load configs
let json_config: Jsonconfig = serde_json::from_reader(fs::File::open(configpath) let json_config: Jsonconfig = serde_json::from_reader(fs::File::open(configpath)
.map_err(|_| Errorfr::ItemJsonMissing)?) .map_err(|_| Errorfr::ItemJsonMissing)?)
.map_err(|_| Errorfr::ItemJsonCorrupt)?; .map_err(|e| Errorfr::ItemJsonCorrupt(e))?;
let idsmap: HashMap<String, u8> = serde_json::from_reader(fs::File::open("id_keys.json") let idsmap: HashMap<String, u8> = serde_json::from_reader(fs::File::open("id_keys.json")
.map_err(|_| Errorfr::IDMapJsonMissing)?) .map_err(|_| Errorfr::IDMapJsonMissing)?)
.map_err(|_| Errorfr::IDMapJsonCorrupt)?; .map_err(|_| Errorfr::IDMapJsonCorrupt)?;