From eb69b5fec4b6d75e8b5d2a54d3a342d8c7a4f595 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 10 Aug 2024 13:59:18 +0200 Subject: pager: fix incorrect error message in rewrite-url It did not actually break rewrite-url, but was still annoying. --- src/local/pager.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/local/pager.nim b/src/local/pager.nim index f39174a9..592db0c6 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -1154,9 +1154,12 @@ proc applySiteconf(pager: Pager; url: var URL; charsetOverride: Charset; let fun = sc.rewrite_url.get var arg0 = ctx.toJS(url) let ret = JS_Call(ctx, fun, JS_UNDEFINED, 1, arg0.toJSValueArray()) - var nu: URL - if ctx.fromJS(ret, nu).isSome: - if nu != nil: + if not JS_IsException(ret): + # Warning: we must only print exceptions if the *call* returned one. + # Conversion may simply error out because the function didn't return a + # new URL, and that's fine. + var nu: URL + if ctx.fromJS(ret, nu).isSome and nu != nil: url = nu else: #TODO should writeException the message to console -- cgit