diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-25 02:01:30 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-25 02:01:30 +0200 |
commit | 790e937795746563246808abaf4b0b25f4a5d0fe (patch) | |
tree | 80e9b360c4ebe601c64488c787860e33ccb1671a /src/local/client.nim | |
parent | da3f78eb9333b7076591ca4088b7f26afc7852ef (diff) | |
download | chawan-790e937795746563246808abaf4b0b25f4a5d0fe.tar.gz |
client: write errors to browser console in evalAction
Diffstat (limited to 'src/local/client.nim')
-rw-r--r-- | src/local/client.nim | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/local/client.nim b/src/local/client.nim index 9d9bb2e6..815d1efb 100644 --- a/src/local/client.nim +++ b/src/local/client.nim @@ -182,15 +182,22 @@ proc handlePagerEvents(client: Client) = client.pager.handleEvents(container) proc evalAction(client: Client, action: string, arg0: int32) = - let ret = client.evalJS(action, "<command>") + var ret = client.evalJS(action, "<command>") let ctx = client.jsctx if JS_IsFunction(ctx, ret): if arg0 != 0: var arg0 = toJS(ctx, arg0) - JS_FreeValue(ctx, JS_Call(ctx, ret, JS_UNDEFINED, 1, addr arg0)) + let ret2 = JS_Call(ctx, ret, JS_UNDEFINED, 1, addr arg0) + JS_FreeValue(ctx, arg0) + JS_FreeValue(ctx, ret) + ret = ret2 JS_FreeValue(ctx, arg0) else: # no precnum - JS_FreeValue(ctx, JS_Call(ctx, ret, JS_UNDEFINED, 0, nil)) + let ret2 = JS_Call(ctx, ret, JS_UNDEFINED, 0, nil) + JS_FreeValue(ctx, ret) + ret = ret2 + if JS_IsException(ret): + client.jsctx.writeException(client.console.err) JS_FreeValue(ctx, ret) # The maximum number we are willing to accept. |