about summary refs log tree commit diff stats
path: root/src/loader/loaderhandle.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-12-15 18:42:21 +0100
committerbptato <nincsnevem662@gmail.com>2023-12-15 18:43:49 +0100
commitdab0d1cd21e216da5551e807489a704ae7b3cb42 (patch)
tree25f736d1b3b76659784ade93ac812a104cc22db4 /src/loader/loaderhandle.nim
parentd67caf71c96629056275432f1ab5b5510db23c0b (diff)
downloadchawan-dab0d1cd21e216da5551e807489a704ae7b3cb42.tar.gz
Implement local CGI error message handling
This was documented, but not implemented until now.

Also, improve the loader module's protocol documentation.
Diffstat (limited to 'src/loader/loaderhandle.nim')
-rw-r--r--src/loader/loaderhandle.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/loader/loaderhandle.nim b/src/loader/loaderhandle.nim
index dda00a1b..65638cdc 100644
--- a/src/loader/loaderhandle.nim
+++ b/src/loader/loaderhandle.nim
@@ -46,9 +46,13 @@ proc addOutputStream*(handle: LoaderHandle, stream: Stream) =
     let ms = newMultiStream(handle.ostream, stream)
     handle.ostream = ms
 
-proc sendResult*(handle: LoaderHandle, res: int): bool =
+proc sendResult*(handle: LoaderHandle, res: int, msg = ""): bool =
   try:
     handle.ostream.swrite(res)
+    if res == 0: # success
+      assert msg == ""
+    else: # error
+      handle.ostream.swrite(msg)
     return true
   except IOError: # broken pipe
     return false