[dancer-users] http_throw and Dancer2

Paul Clements paul.clements at us.sios.com
Thu Feb 4 13:44:15 EST 2021

On Thu, Feb 4, 2021 at 5:34 AM Andrew Beverley <andy at andybev.com> wrote:
> On Wed, 3 Feb 2021 17:49:05 -0500 Paul Clements wrote:
> > I've been trying for a while now to figure out the best way to handle
> > exceptions with Dancer2.
> Do you mean "expected" or "unexpected" exceptions? I.e. exceptions you
> use for application flow, or ones that are as a result of internal bugs.

Sorry, I should have been more clear. I'm developing an API, and I'm
mostly looking to handle what you call expected exceptions. The PSGI
HTTPExceptions module seems to be along the lines of what I'm looking

The idea is to have a single, simple way from anywhere in the codebase
to return, say, an HTTP 400 error (wrapped in JSON) to the API user.
Some authentication util methods would probably also like to return a
401 or 403 for certain conditions.

So, ideally, I'd rather not have anything grab and rethrow exceptions
as strings (as seems to happen now in a few places in the Dancer2
codebase). I guess I'm really looking for a way to avoid or circumvent
what seems to be the default Dancer exception handling behavior.

-- Paul

More information about the dancer-users mailing list