Chain config context with ErrorContext
Assisted-by: GLM-5.3 via pi
diff --git a/src/error.rs b/src/error.rs
index fc0f986..59af5ec 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -4,16 +4,12 @@ use miette::Diagnostic;
#[derive(Debug, thiserror::Error, Diagnostic)]
pub enum Error {
- #[error("failed to load config {}", .path.display())]
+ #[error("failed to load config")]
#[diagnostic(
code(parallax::config),
help("the config must be a Fennel file; fix the reported syntax or validation error")
)]
- Config {
- path: PathBuf,
- #[source]
- error: mlua::Error,
- },
+ Config(#[from] mlua::Error),
#[error("{} must call ({what} ...)", .path.display())]
#[diagnostic(
diff --git a/src/parallax.rs b/src/parallax.rs
index 25a2a9f..81e5315 100644
--- a/src/parallax.rs
+++ b/src/parallax.rs
@@ -5,6 +5,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use std::sync::MutexGuard;
+use mlua::ErrorContext as _;
use mlua::Function;
use mlua::Lua;
use mlua::LuaSerdeExt as _;
@@ -61,10 +62,8 @@ impl Parallax {
setup,
server,
flows,
- } = run_config(&lua, &source, &filename, &stash).map_err(|error| Error::Config {
- path: path.to_path_buf(),
- error,
- })?;
+ } = run_config(&lua, &source, &filename, &stash)
+ .with_context(|_| format!("loading {}", path.display()))?;
let setup = setup.ok_or_else(|| Error::ConfigRegistration {
path: path.to_path_buf(),