Add simple error handling

This commit is contained in:
Jeroen van Dijk 2021-05-26 17:54:39 +03:00
parent b8a0957530
commit fc15e8a5ac

View file

@ -18,14 +18,21 @@
(defn bookmarklet-href [code]
(str "javascript:(function(){"
"var code='" code "';"
"var runCode = function() {
try {
scittle.core.eval_string('" code "')
} catch (error) {
console.log('Error in code', error);
alert('Error running code, see console')
}
};"
"if(typeof scittle === 'undefined'){"
(append-tag :script {:src "https://borkdude.github.io/scittle/js/scittle.js"
:onerror "function(){alert('Error loading ' + this.src)}"
:onload (str "function(){scittle.core.eval_string(code)}")
:onload (str "runCode")
})
"} else {
scittle.core.eval_string(code) }"
runCode() }"
"})();"))
(defn workspace []