about summary refs log tree commit diff stats
path: root/src/html/dom.nim
diff options
context:
space:
mode:
Diffstat (limited to 'src/html/dom.nim')
-rw-r--r--src/html/dom.nim15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 2fa50e3b..e4325b18 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -3533,13 +3533,14 @@ proc execute*(element: HTMLScriptElement) =
     if window != nil and window.jsctx != nil:
       let script = element.scriptResult.script
       let urls = script.baseURL.serialize(excludepassword = true)
-      let ret = window.jsctx.evalFunction(script.record)
-      if JS_IsException(ret):
-        let ss = newStringStream()
-        document.window.jsctx.writeException(ss)
-        ss.setPosition(0)
-        document.window.console.log("Exception in document", urls,
-          ss.readAll())
+      if JS_IsException(script.record):
+        let s = document.window.jsctx.getExceptionStr()
+        document.window.console.log("Exception in document", urls, s)
+      else:
+        let ret = window.jsctx.evalFunction(script.record)
+        if JS_IsException(ret):
+          let s = document.window.jsctx.getExceptionStr()
+          document.window.console.log("Exception in document", urls, s)
     document.currentScript = oldCurrentScript
   else: discard #TODO
   if needsInc: