summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-05-09 13:16:24 +0200
committerTor Andersson <tor@ccxvii.net>2025-05-12 00:09:39 +0200
commite0f06319afc4d77f1e6141f3b0cc840470e895c5 (patch)
tree01e95a9dfdf44a14e146f95808cf57e9f9a0cc8a /public
parent41e604f3eb306c2e74a9cfca6af32ce6a03a3eff (diff)
downloadserver-e0f06319afc4d77f1e6141f3b0cc840470e895c5.tar.gz
More framework error handling.
Docs typo.
Diffstat (limited to 'public')
-rw-r--r--public/common/framework.js25
1 files changed, 18 insertions, 7 deletions
diff --git a/public/common/framework.js b/public/common/framework.js
index a1601b7..f0a1abe 100644
--- a/public/common/framework.js
+++ b/public/common/framework.js
@@ -225,12 +225,16 @@ function _run() {
for (var i = 0; i < 1000 && L; ++i) {
var prog = P[L.P]
if (prog) {
- if (typeof prog === "function")
+ if (typeof prog === "function") {
prog()
- else if (L.I < prog.length)
- prog[L.I++]()
- else
- end()
+ } else if (Array.isArray(prog)) {
+ if (L.I < prog.length)
+ prog[L.I++]()
+ else
+ end()
+ } else {
+ throw new Error("invalid procedure: P." + L.P)
+ }
} else {
return
}
@@ -483,12 +487,19 @@ function _parse(text) {
function script(text) {
script.cache ??= {}
+ var prog = []
try {
- return _parse(text).map(inst => script.cache[inst] ??= eval("(function(){" + inst + "})"))
+ for (var inst of _parse(text)) {
+ try {
+ prog.push(script.cache[inst] ??= eval("(function(){" + inst + "})"))
+ } catch (err) {
+ return err.message + " - " + inst
+ }
+ }
} catch (err) {
- // return the error message so we can attach the script name and re-raise later
return err.message
}
+ return prog
}
(function () {