Skip to content

"error" block of Jester does not work when using custom routers #211

Closed
@hokamoto

Description

@hokamoto

This issue is from https://forum.nim-lang.org/t/5196

"error" block of Jester does not work when using custom routers. The below code dumps a stack trace instead of the expected message "An exception occurred".

import asyncdispatch, jester, os, strutils, htmlgen

router myrouter:
  get "/":
    raise(newException(OSError, "exception"))
  
  error Exception:
    resp h1("An exception occurred")

proc main() =
  let port = Port(5000)
  let settings = newSettings(port=port)
  var jester = initJester(myrouter, settings=settings)
  jester.serve()

when isMainModule:
  main()
$ nim -v
Nim Compiler Version 0.20.2 [MacOSX: amd64]
Compiled at 2019-07-18
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release -d:useLinenoise
$ nimble list -i --ver
asynctools  [#pr_fix_compilation]
httpbeast  [0.2.2]
jester  [#head]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions