mirror of
https://github.com/wez/wezterm.git
synced 2024-12-23 13:21:38 +03:00
lua api: improve error handling
Don't prevent wezterm from starting up if the gui-startup event errors out. Show a toast notification with the error message. refs: #674
This commit is contained in:
parent
fa02f6d5f0
commit
66033e4c6d
@ -399,20 +399,18 @@ async fn async_run_terminal_gui(
|
||||
async fn trigger_gui_startup(lua: Option<Rc<mlua::Lua>>) -> anyhow::Result<()> {
|
||||
if let Some(lua) = lua {
|
||||
let args = lua.pack_multi(())?;
|
||||
config::lua::emit_event(&lua, ("gui-startup".to_string(), args))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("while processing gui-startup event: {:#}", e);
|
||||
e
|
||||
})?;
|
||||
config::lua::emit_event(&lua, ("gui-startup".to_string(), args)).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
promise::spawn::spawn(config::with_lua_config_on_main_thread(move |lua| {
|
||||
trigger_gui_startup(lua)
|
||||
}))
|
||||
.await?;
|
||||
if let Err(err) =
|
||||
config::with_lua_config_on_main_thread(move |lua| trigger_gui_startup(lua)).await
|
||||
{
|
||||
let message = format!("while processing gui-startup event: {:#}", err);
|
||||
log::error!("{}", message);
|
||||
persistent_toast_notification("Error", &message);
|
||||
}
|
||||
|
||||
let is_connecting = false;
|
||||
spawn_tab_in_default_domain_if_mux_is_empty(cmd, is_connecting).await
|
||||
|
@ -202,12 +202,7 @@ fn run() -> anyhow::Result<()> {
|
||||
async fn trigger_mux_startup(lua: Option<Rc<mlua::Lua>>) -> anyhow::Result<()> {
|
||||
if let Some(lua) = lua {
|
||||
let args = lua.pack_multi(())?;
|
||||
config::lua::emit_event(&lua, ("mux-startup".to_string(), args))
|
||||
.await
|
||||
.map_err(|e| {
|
||||
log::error!("while processing mux-startup event: {:#}", e);
|
||||
e
|
||||
})?;
|
||||
config::lua::emit_event(&lua, ("mux-startup".to_string(), args)).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -218,7 +213,11 @@ async fn async_run(cmd: Option<CommandBuilder>) -> anyhow::Result<()> {
|
||||
let domain = mux.default_domain();
|
||||
|
||||
{
|
||||
config::with_lua_config_on_main_thread(move |lua| trigger_mux_startup(lua)).await?;
|
||||
if let Err(err) =
|
||||
config::with_lua_config_on_main_thread(move |lua| trigger_mux_startup(lua)).await
|
||||
{
|
||||
log::error!("while processing mux-startup event: {:#}", err);
|
||||
}
|
||||
}
|
||||
|
||||
let have_panes_in_domain = mux
|
||||
|
Loading…
Reference in New Issue
Block a user