report plugin errors to the user

This commit is contained in:
Christof Petig
2024-03-14 00:21:18 +01:00
parent 8dd4729965
commit 166653b355
3 changed files with 17 additions and 11 deletions

View File

@ -243,7 +243,7 @@ impl PluginMgr {
base_dir: &Path, base_dir: &Path,
data: Vec<u8>, data: Vec<u8>,
) -> Result<PluginHash, PluginError> { ) -> Result<PluginHash, PluginError> {
let path = store_server_plugin(base_dir, data)?; let path = store_server_plugin(base_dir, data).map_err(PluginError::Io)?;
self.load_server_plugin(path) self.load_server_plugin(path)
} }

View File

@ -282,16 +282,19 @@ impl PlayState for CharSelectionState {
tracing::info!("plugin data {}", data.len()); tracing::info!("plugin data {}", data.len());
let mut client = self.client.borrow_mut(); let mut client = self.client.borrow_mut();
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
if let Ok(hash) = client match client
.state() .state()
.ecs() .ecs()
.write_resource::<PluginMgr>() .write_resource::<PluginMgr>()
.cache_server_plugin(&global_state.config_dir, data) .cache_server_plugin(&global_state.config_dir, data)
{ {
Ok(hash) => {
if client.plugin_received(hash) == 0 { if client.plugin_received(hash) == 0 {
// now load characters (plugins might contain items) // now load characters (plugins might contain items)
client.load_character_list(); client.load_character_list();
} }
},
Err(e) => tracing::error!(?e, "cache_server_plugin"),
} }
}, },
// TODO: See if we should handle StartSpectate here instead. // TODO: See if we should handle StartSpectate here instead.

View File

@ -284,16 +284,19 @@ impl PlayState for MainMenuState {
tracing::info!("plugin data {}", data.len()); tracing::info!("plugin data {}", data.len());
if let InitState::Pipeline(client) = &mut self.init { if let InitState::Pipeline(client) = &mut self.init {
#[cfg(feature = "plugins")] #[cfg(feature = "plugins")]
if let Ok(hash) = client match client
.state() .state()
.ecs() .ecs()
.write_resource::<PluginMgr>() .write_resource::<PluginMgr>()
.cache_server_plugin(&global_state.config_dir, data) .cache_server_plugin(&global_state.config_dir, data)
{ {
Ok(hash) => {
if client.plugin_received(hash) == 0 { if client.plugin_received(hash) == 0 {
// now load characters (plugins might contain items) // now load characters (plugins might contain items)
client.load_character_list(); client.load_character_list();
} }
},
Err(e) => tracing::error!(?e, "cache_server_plugin"),
} }
} }
}, },