about summary refs log tree commit diff stats
path: root/src/html
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-01-04 01:18:59 +0100
committerbptato <nincsnevem662@gmail.com>2023-01-04 01:18:59 +0100
commit181ea25b5626c697cc9b6bd3e42c85ea920be0f3 (patch)
tree92338bdbf5743ac2e5c383b6abe13ec3518ed433 /src/html
parenteda263319d5f6b4f7392398a42d67f04056c23e1 (diff)
downloadchawan-181ea25b5626c697cc9b6bd3e42c85ea920be0f3.tar.gz
client, pager, dom, ...: better error handling
Now the browser shouldn't completely die when a buffer crashes.
Diffstat (limited to 'src/html')
-rw-r--r--src/html/dom.nim12
-rw-r--r--src/html/env.nim4
2 files changed, 8 insertions, 8 deletions
diff --git a/src/html/dom.nim b/src/html/dom.nim
index 6f98d9d4..228f48e1 100644
--- a/src/html/dom.nim
+++ b/src/html/dom.nim
@@ -97,7 +97,7 @@ type
   # this and the Client console.
   # TODO: merge those two
   console* = ref object
-    err: Stream
+    err*: Stream
 
   NamedNodeMap = ref object
     element: Element
@@ -1965,18 +1965,16 @@ proc fetchClassicScript(element: HTMLScriptElement, url: URL,
         let script = createClassicScript(source, url, options, false)
         element.markAsReady(ScriptResult(t: RESULT_SCRIPT, script: script))
 
-#TODO TODO TODO do something with this (redirect stderr?)
 proc log*(console: console, ss: varargs[string]) {.jsfunc.} =
   var s = ""
   for i in 0..<ss.len:
     s &= ss[i]
-    #console.err.write(ss[i])
+    console.err.write(ss[i])
     if i != ss.high:
       s &= ' '
-      #console.err.write(' ')
-  eprint s
-  #console.err.write('\n')
-  #console.err.flush()
+      console.err.write(' ')
+  console.err.write('\n')
+  console.err.flush()
 
 proc execute*(element: HTMLScriptElement) =
   let document = element.document
diff --git a/src/html/env.nim b/src/html/env.nim
index a232baa5..7f270e58 100644
--- a/src/html/env.nim
+++ b/src/html/env.nim
@@ -1,3 +1,5 @@
+import streams
+
 import html/dom
 import html/htmlparser
 import io/loader
@@ -51,7 +53,7 @@ proc addNavigatorModule(ctx: JSContext) =
 
 proc newWindow*(scripting: bool, loader = none(FileLoader)): Window =
   result = Window(
-    console: console(),
+    console: console(err: newFileStream(stderr)),
     navigator: Navigator(),
     loader: loader,
     settings: EnvironmentSettings(