From 1f1ae642e8cba75b91b2f49f1e499aae7c46d85c Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 6 Jun 2025 19:10:28 +0200 Subject: better error reporting on server map load --- server/src/data/mod.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/server/src/data/mod.rs b/server/src/data/mod.rs index 64f40217..4b74fe28 100644 --- a/server/src/data/mod.rs +++ b/server/src/data/mod.rs @@ -149,18 +149,26 @@ impl DataIndex { Ok(read_to_string(path).await?) } pub async fn generate(&self, map: &str) -> Result<(Gamedata, Serverdata, Entities)> { - let map_in: MapDecl = serde_yml::from_str(&self.read_map(map).await?)?; + let map_in: MapDecl = serde_yml::from_str( + &self + .read_map(map) + .await + .context(anyhow!("Failed to read map file ({map})"))?, + ) + .context(anyhow!("Failed to parse map file ({map})"))?; let recipes_in = serde_yml::from_str( &self .read_recipes(map_in.recipes.as_deref().unwrap_or("default")) - .await?, - )?; + .await + .context("Failed read recipe file")?, + ) + .context("Failed to parse recipe file")?; let book = serde_json::from_str( &read_to_string(data_dir().join("book.json")) .await - .context("loading book")?, + .context("Failed to read book file")?, ) - .context("invalid book")?; + .context("Failed to parse book file")?; build_data(&self.maps, map.to_string(), map_in, recipes_in, book) } } -- cgit v1.2.3-70-g09d2