From 790e937795746563246808abaf4b0b25f4a5d0fe Mon Sep 17 00:00:00 2001 From: bptato Date: Mon, 25 Sep 2023 02:01:30 +0200 Subject: client: write errors to browser console in evalAction --- src/local/client.nim | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/local/client.nim') 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, "") + var ret = client.evalJS(action, "") 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. -- cgit 1.4.1-2-gfad0