diff --git a/src/js/rulesAssistant.js b/src/js/rulesAssistant.js index 2e19e7e90c7bb7fbd8c9b1abb5ff88b6ea75a119..a0cff070126a08b73d5fb8df19bcaed40c89cd0a 100644 --- a/src/js/rulesAssistant.js +++ b/src/js/rulesAssistant.js @@ -151,7 +151,12 @@ globalThis.ruleAppliesP = function(rule, slave) { break; case "custom": // user provided JS function // TODO: This should use a cached Function instead of 'eval'ing - flag = eval(cond.data)(slave); + try { + flag = eval(cond.data)(slave); + } catch (e) { + // Put together a more useful message for the player. Does mean we are losing the stacktrace. + throw new Error(`Rule '${rule.name}' custom condition failed: '${e.message}'`); + } break; } if (!flag) {