[Dancer-users] May I have some help with issue #561

Brian E. Lozier brian at massassi.com
Tue Jun 28 16:47:03 CEST 2011

Issue #561 ( https://github.com/sukria/Dancer/issues/561 ) is really
killing me and due to the design of Dancer I can't find a simple way
around it.  The crux of the issue is that in Dancer::Factory::Hooks
all the hooks get executed and their return values aren't checked.
The hooks are initially compiled in Dancer::Hook and they are compiled
wrapped in an eval such that if an exception occurs the hook returns a
Dancer::halt which in turns wraps a Dancer::Response object that wraps
an error render.  Unfortunately nothing is ever done with this error
render and I don't see a standard way to actually "halt" processing.
If an exception occurs in a hook we should never ignore it and
continue processing the rest of the page!  We should die immediately
and print an error message to the screen.  The Dancer::halt method
just returns a Dancer::Response object, it doesn't actually stop

As it works now, the returned Dancer::Response object is (almost)
completely ignored.  In fact the status code gets persisted to the
actual Dancer::Response that is served (500) but the page renders
normally otherwise.

We are so deep in the call stack when hooks are executed that it's
impossible to have any meaningful "return" value (unless someone goes
in to every place "execute_hooks" is called and actually checks for
errors -- in this case it would have to check for Dancer::Response

Is there a method somewhere that really halts instead of just
returning a Dancer::Response object?  Is there an accepted way to
short-circuit the rest of the request handling?


More information about the Dancer-users mailing list