diff options
author | metamuffin <metamuffin@disroot.org> | 2025-06-06 19:10:28 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-06-06 19:10:28 +0200 |
commit | 1f1ae642e8cba75b91b2f49f1e499aae7c46d85c (patch) | |
tree | 887eca3629a7eeebc428703d1981b2bb9dac4d97 | |
parent | e7385c738a12e32d36e97f80f26fabdb5223f36e (diff) | |
download | hurrycurry-1f1ae642e8cba75b91b2f49f1e499aae7c46d85c.tar hurrycurry-1f1ae642e8cba75b91b2f49f1e499aae7c46d85c.tar.bz2 hurrycurry-1f1ae642e8cba75b91b2f49f1e499aae7c46d85c.tar.zst |
better error reporting on server map load
-rw-r--r-- | server/src/data/mod.rs | 18 |
1 files 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) } } |