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,
data: Vec<u8>,
) -> 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)
}

View File

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