about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/js/javascript.nim4
-rw-r--r--src/js/tojs.nim7
2 files changed, 4 insertions, 7 deletions
diff --git a/src/js/javascript.nim b/src/js/javascript.nim
index 44c7ef06..57baff45 100644
--- a/src/js/javascript.nim
+++ b/src/js/javascript.nim
@@ -548,8 +548,6 @@ template fromJS_or_return*(t, ctx, val: untyped): untyped =
   (
     let x = fromJS[t](ctx, val)
     if x.isErr:
-      if x.error == nil:
-        return JS_EXCEPTION
       return toJS(ctx, x.error)
     x.get
   )
@@ -558,8 +556,6 @@ template fromJSP_or_return*(t, ctx, val: untyped): untyped =
   (
     let x = fromJSP[t](ctx, val)
     if x.isErr:
-      if x.error == nil:
-        return JS_EXCEPTION
       return toJS(ctx, x.error)
     x.get
   )
diff --git a/src/js/tojs.nim b/src/js/tojs.nim
index ea6f35f2..bf2af7cc 100644
--- a/src/js/tojs.nim
+++ b/src/js/tojs.nim
@@ -210,9 +210,8 @@ proc toJS[T, E](ctx: JSContext; opt: Result[T, E]): JSValue =
       return JS_UNDEFINED
   else:
     when not (E is void):
-      let res = toJS(ctx, opt.error)
-      if not JS_IsNull(res):
-        return JS_Throw(ctx, res)
+      if opt.error != nil:
+        return JS_Throw(ctx, toJS(ctx, opt.error))
     return JS_EXCEPTION
 
 proc toJS(ctx: JSContext; s: seq): JSValue =
@@ -376,6 +375,8 @@ proc toJS[T, E](ctx: JSContext; promise: Promise[Result[T, E]]): JSValue =
   return jsPromise
 
 proc toJS*(ctx: JSContext; err: JSError): JSValue =
+  if err == nil:
+    return JS_EXCEPTION
   if err.e notin QuickJSErrors:
     return toJSRefObj(ctx, err)
   var msg = toJS(ctx, err.message)
garam <vc@akkartik.com> 2020-09-22 10:20:12 -0700 6834' href='/akkartik/mu/commit/406try-divide.mu?h=main&id=afacec5e43da4a929a8401b84cc6f3f5533258cc'>afacec5e ^
797c93e0 ^



afacec5e ^
797c93e0 ^



afacec5e ^
797c93e0 ^



afacec5e ^
797c93e0 ^
e655f673 ^
e981b8f6 ^
e655f673 ^
e981b8f6 ^


e655f673 ^
e981b8f6 ^












e655f673 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105