diff options
| author | srdusr <[email protected]> | 2025-02-17 22:04:00 +0200 |
|---|---|---|
| committer | srdusr <[email protected]> | 2025-02-17 22:04:00 +0200 |
| commit | 78d889c48e5b1336c73f28a2e2d5c8a571c7dd43 (patch) | |
| tree | 4f930c85e79f5f37a3c4e515de885cf1f80f2314 /crates/config | |
| parent | 0a4c4b5941fe982ccb3d3175e26d9d83f0025ffd (diff) | |
| parent | f7c6e9c607742ed373752aadf5761e99ec3eb64a (diff) | |
| download | srdwm-78d889c48e5b1336c73f28a2e2d5c8a571c7dd43.tar.gz srdwm-78d889c48e5b1336c73f28a2e2d5c8a571c7dd43.zip | |
Merge branch 'main' into rust-rewrite
# Conflicts:
# crates/config/src/engine/general.rs
# crates/wayland/src/udev/drm.rs
# crates/wayland/src/udev/mod.rs
# crates/wayland/src/udev/render.rs
# crates/wayland/src/winit/render.rs
Diffstat (limited to 'crates/config')
| -rw-r--r-- | crates/config/src/engine/general.rs | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/crates/config/src/engine/general.rs b/crates/config/src/engine/general.rs index 94b029b..e5147cd 100644 --- a/crates/config/src/engine/general.rs +++ b/crates/config/src/engine/general.rs @@ -229,14 +229,40 @@ impl Engine { })?) } + /// `srd.load("keybindings")`/`"themes"`/`"rules"`/`"startup"`: each is + /// its own file, its own logical concern, and - deliberately, since + /// this function catches its own execution error rather than letting + /// `?` propagate one - its own failure domain. A `mlua::Error` from + /// one module used to unwind straight out through this function and + /// back into whatever was running `init.lua` itself, aborting every + /// statement after that `srd.load` call, including every *other* + /// `srd.load` - a typo in `rules.lua` silently took `startup.lua` + /// (autostart) down with it, and there was no way from the config + /// author's side to prevent that, short of never making a mistake. + /// Reproduced live in the worse but related case (the error was in + /// `init.lua` itself, above every `srd.load` call, which this + /// function alone can't isolate against): a session that started with + /// nothing but a bare cursor, zero autostart, zero keybindings, no + /// error visible anywhere except one `WARN` line in a multi-hundred- + /// megabyte log file. A module failing now still leaves the user + /// without whatever that module would have set up, logged clearly at + /// `error` level with the module name and the file path - but + /// everything *else* `init.lua` goes on to load still does. pub(super) fn fn_load(&self) -> Result<mlua::Function<'_>> { let state = self.state.clone(); Ok(self.lua.create_function(move |lua, module: String| { let dir = state.borrow().config_dir.clone(); let path = dir.join(format!("{module}.lua")); - let src = std::fs::read_to_string(&path) - .map_err(|e| mlua::Error::RuntimeError(format!("srd.load('{module}'): {e} ({})", path.display())))?; - lua.load(&src).set_name(path.to_string_lossy().as_ref()).exec()?; + let src = match std::fs::read_to_string(&path) { + Ok(src) => src, + Err(e) => { + log::error!("srd.load('{module}'): {e} ({}) - this module did not load, but the rest of init.lua still will", path.display()); + return Ok(()); + } + }; + if let Err(e) = lua.load(&src).set_name(path.to_string_lossy().as_ref()).exec() { + log::error!("srd.load('{module}'): {e} - this module did not finish loading, but the rest of init.lua still will"); + } Ok(()) })?) } |