about summary refs log tree commit diff stats
path: root/src/xhr/formdata.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-19 20:16:39 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-19 20:17:06 +0200
commit82fb1f70ab275884c42dd769b2af8f9df5389e88 (patch)
treeb7a83ca2e2d22e926959f2525169f2a2e4530e38 /src/xhr/formdata.nim
parent070cfca46f60c3a00fe6dd66457f454a1a217897 (diff)
downloadchawan-82fb1f70ab275884c42dd769b2af8f9df5389e88.tar.gz
Get rid of the .jserr pragma
Diffstat (limited to 'src/xhr/formdata.nim')
-rw-r--r--src/xhr/formdata.nim15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/xhr/formdata.nim b/src/xhr/formdata.nim
index cbb9f63e..a1832274 100644
--- a/src/xhr/formdata.nim
+++ b/src/xhr/formdata.nim
@@ -1,5 +1,6 @@
 import html/dom
 import html/tags
+import js/exception
 import js/javascript
 import types/blob
 import types/formdata
@@ -8,18 +9,22 @@ import utils/twtstr
 proc constructEntryList*(form: HTMLFormElement, submitter: Element = nil,
     encoding: string = ""): Option[seq[FormDataEntry]]
 
+proc newFormData0*(): FormData =
+  return FormData()
+
 proc newFormData*(form: HTMLFormElement = nil,
-    submitter: HTMLElement = nil): FormData {.jserr, jsctor.} =
+    submitter: HTMLElement = nil): Result[FormData, JSError] {.jsctor.} =
   let this = FormData()
   if form != nil:
     if submitter != nil:
       if not submitter.isSubmitButton():
-        JS_ERR JS_TypeError, "Submitter must be a submit button"
+        return err(newDOMException("Submitter must be a submit button",
+          "InvalidStateError"))
       if FormAssociatedElement(submitter).form != form:
-        #TODO should be DOMException
-        JS_ERR JS_TypeError, "InvalidStateError"
+        return err(newDOMException("Submitter's form owner is not form",
+          "InvalidStateError"))
     this.entries = constructEntryList(form, submitter).get(@[])
-  return this
+  return ok(this)
 
 #TODO as jsfunc
 proc append*(this: FormData, name: string, svalue: string, filename = "") =