about summary refs log tree commit diff stats
path: root/src/io/request.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-09 15:27:29 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-09 15:27:29 +0200
commite8fa2217df7bacc58e88737f21752bbdf0f5562a (patch)
tree8fbec22f273f2cab5811b2f9b1dd5ea05496ef1a /src/io/request.nim
parentb39e35e46773258cb103397b2372612308c22ae0 (diff)
downloadchawan-e8fa2217df7bacc58e88737f21752bbdf0f5562a.tar.gz
Show error messages, fix some fetch crashes
Diffstat (limited to 'src/io/request.nim')
-rw-r--r--src/io/request.nim2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/io/request.nim b/src/io/request.nim
index ed38ad47..4a123a0b 100644
--- a/src/io/request.nim
+++ b/src/io/request.nim
@@ -326,6 +326,8 @@ proc Response_json(ctx: JSContext, this: JSValue, argc: cint, argv: ptr JSValue)
     return JS_ThrowTypeError(ctx, "Value is not an instance of %s", "Response")
   let response = cast[Response](op)
   var s = response.text()
+  if s == "":
+    return JS_ThrowSyntaxError("unexpected end of input")
   return JS_ParseJSON(ctx, addr s[0], cast[csize_t](s.len), cstring"<input>")
 
 func credentialsMode*(attribute: CORSAttribute): CredentialsMode =