diff --git a/CHANGELOG.md b/CHANGELOG.md index 1101601..d88c0c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,11 +18,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/). - Faster re-evaluation of configuration by reusing compiled configuration. - Improved runtime error handling of WidgetNode casting. - Caching for ParseConfig in re-evaluation system. -- Proper error handling for invalid external module code. +- Proper error handling for runtime error in external module code. - **call-fns** command for calling a Rhai function. Note: The function can only see poll/listen variables as their initial value. - **update** command with **--inject-vars** flag to update widget state. Note: All poll/listen variables will reset to their initial values. - `std::command` module for running shell commands. - `INPUT_VAL` environment variable for Input widget commands (`onchange` and `onaccept`), containing the current text of the input field. +- Parse error handling for external module code. ### Changed diff --git a/crates/iirhai/src/module_resolver.rs b/crates/iirhai/src/module_resolver.rs index eb07e0b..5c89d04 100644 --- a/crates/iirhai/src/module_resolver.rs +++ b/crates/iirhai/src/module_resolver.rs @@ -1,4 +1,4 @@ -use crate::error::format_eval_error; +use crate::error::{format_eval_error, format_parse_error}; use rhai::{Engine, EvalAltResult, Module, ModuleResolver, Position, Scope, AST}; use std::fs; use std::path::PathBuf; @@ -43,7 +43,10 @@ impl ModuleResolver for SimpleFileResolver { EvalAltResult::ErrorSystem(format!("reading file: {full_path:?}"), e.into()) })?; - let ast: AST = engine.compile(&script)?; + let ast: AST = engine.compile(&script).map_err(|e| { + log::error!("{}", format_parse_error(&e, &script)); + e + })?; let scope = Scope::new(); let mut module = Module::eval_ast_as_new(scope, &ast, engine).map_err(|e| { log::error!("{}", format_eval_error(&e, &script, engine));