Router.register should not raise exception

This commit is contained in:
jangko 2024-01-13 15:36:47 +07:00
parent 66208055bc
commit f90e946b6a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9

View File

@ -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