From 2a1a8855d8a6603c9643da2fbdfa58623df3c89a Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Sun, 9 Oct 2022 19:56:47 +0200 Subject: [PATCH] Handle errors during save/load --- planet/src/lib.rs | 4 ++-- src/main.rs | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/planet/src/lib.rs b/planet/src/lib.rs index f67479e..31c0daa 100644 --- a/planet/src/lib.rs +++ b/planet/src/lib.rs @@ -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; diff --git a/src/main.rs b/src/main.rs index c641506..3a13980 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); - refresh_map_texture( - &mut images, - #[cfg(feature = "globe_view")] - &mut materials, - &world_manager, - ); + 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 => {