[dancer-users] http_throw and Dancer2

Paul Clements paul.clements at us.sios.com
Wed Feb 3 22:49:05 EST 2021


I've been trying for a while now to figure out the best way to handle
exceptions with Dancer2.

I like the simplicity of http_throw. However, I've not been able to
get that to work successfully with Dancer2 without this workaround:

https://pastebin.com/wLsUBJhN

(The test shows a PSGI app with HTTPExceptions enabled, which allows
proper use of http_throw. It also shows a sample Dancer2 app with my
workaround to allow use of http_throw.)

Basically, it appears that Dancer2 wants to intercept any exception
and rethrow it as 500 (Internal Server Error) without some hacky hook
code to intercept the exception and re-apply it later.

Has anyone dealt with this issue? Is there a better way to handle this
(some middleware or config option)?

Thanks,
Paul


More information about the dancer-users mailing list