diff options
author | nokoe <nokoe@mailbox.org> | 2024-06-27 13:18:19 +0200 |
---|---|---|
committer | nokoe <nokoe@mailbox.org> | 2024-06-27 13:18:19 +0200 |
commit | 9e018943b48405ee75744883dd2fd8f7600bc19e (patch) | |
tree | 8a5b4033b997ad430b11b03b916cc39e64263d87 /server/src | |
parent | 191d480ed63f445436a996afeb6242b89ca24fc2 (diff) | |
download | hurrycurry-9e018943b48405ee75744883dd2fd8f7600bc19e.tar hurrycurry-9e018943b48405ee75744883dd2fd8f7600bc19e.tar.bz2 hurrycurry-9e018943b48405ee75744883dd2fd8f7600bc19e.tar.zst |
replace unwrap with context
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/data.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/src/data.rs b/server/src/data.rs index e2944e3d..6b0442ce 100644 --- a/server/src/data.rs +++ b/server/src/data.rs @@ -19,7 +19,7 @@ use crate::{ interaction::Recipe, protocol::{DemandIndex, ItemIndex, RecipeIndex, TileIndex}, }; -use anyhow::{anyhow, bail, Result}; +use anyhow::{anyhow, bail, Context, Result}; use glam::{IVec2, Vec2}; use serde::{Deserialize, Serialize}; use std::{ @@ -142,9 +142,12 @@ impl DataIndex { let map_path = data_dir().join(format!("maps/{map}.yaml")); let recipes_path = data_dir().join(format!("recipes/{recipes}.yaml")); - let demands_in = serde_yaml::from_reader(File::open(demands_path).unwrap()).unwrap(); - let map_in = serde_yaml::from_reader(File::open(map_path).unwrap()).unwrap(); - let recipes_in = serde_yaml::from_reader(File::open(recipes_path).unwrap()).unwrap(); + let demands_in = + serde_yaml::from_reader(File::open(demands_path).context("opening demands failed")?)?; + let map_in = serde_yaml::from_reader(File::open(map_path).context("opening map failed")?)?; + let recipes_in = serde_yaml::from_reader( + File::open(recipes_path).context("opening recipes failed. are they generated yet?")?, + )?; Ok(Gamedata::build(recipes_in, map_in, demands_in)?) } |