Skip to content

Commit

Permalink
Router.register should not raise exception
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Jan 13, 2024
1 parent 6620805 commit f90e946
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions json_rpc/router.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f90e946

Please sign in to comment.