From f90e946b6a92432cbfe7abb59f9c05af17bfddde Mon Sep 17 00:00:00 2001 From: jangko Date: Sat, 13 Jan 2024 15:36:47 +0700 Subject: [PATCH] Router.register should not raise exception --- json_rpc/router.nim | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/json_rpc/router.nim b/json_rpc/router.nim index 6b44ffe..248f79d 100644 --- a/json_rpc/router.nim +++ b/json_rpc/router.nim @@ -110,9 +110,12 @@ proc wrapError(code: int, msg: string): string = proc init*(T: type RpcRouter): T = discard -proc register*(router: var RpcRouter, path: string, call: RpcProc) - {.gcsafe, raises: [CatchableError].} = - router.procs[path] = call +proc register*(router: var RpcRouter, path: string, call: RpcProc) = + # this proc should not raise exception + try: + router.procs[path] = call + except CatchableError as exc: + doAssert(false, exc.msg) proc clear*(router: var RpcRouter) = router.procs.clear