Handle errors during save/load

This commit is contained in:
Tobias Berger 2022-10-09 19:56:47 +02:00
parent 4e163b7345
commit 2a1a8855d8
Signed by: toby
GPG key ID: 2D05EFAB764D6A88
2 changed files with 15 additions and 10 deletions

View file

@ -33,9 +33,9 @@
#![warn(variant_size_differences)]
pub mod world;
pub use world::*;
pub use world::{TerrainCell, World, WorldGenError};
pub mod biome;
pub use biome::*;
pub use biome::{BiomeStats, BiomeType};
pub mod world_manager;
pub use world_manager::WorldManager;
pub(crate) mod macros;

View file

@ -269,18 +269,23 @@ fn handle_toolbar_button(
ToolbarButton::SaveWorld => {
#[cfg(feature = "logging")]
debug!("Saving world");
_ = world_manager.save_world("planet.ron");
if let Err(err) = world_manager.save_world("planet.ron") {
eprintln!("Failed to save planet.ron: {}", err);
}
},
ToolbarButton::LoadWorld => {
#[cfg(feature = "logging")]
debug!("Loading world");
_ = world_manager.load_world("planet.ron", &mut images);
if let Err(err) = world_manager.load_world("planet.ron", &mut images) {
eprintln!("Failed to load planet.ron: {}", err);
} else {
refresh_map_texture(
&mut images,
#[cfg(feature = "globe_view")]
&mut materials,
&world_manager,
);
}
},
#[cfg(feature = "globe_view")]
ToolbarButton::GlobeView => {