[Dancer-users] Dancer2 - feature change request
Assaf Gordon
gordon at cshl.edu
Fri Oct 21 21:18:19 CEST 2011
Richard Huxton wrote, On 10/21/11 05:55:
> Since dancer2 is on the way, I thought I'd be cheeky and suggest a slight change in functionality (rather than wait until dancer3). Does anyone (particularly core devs of course) have any strong opinions on the following?
>
While we're at the topic of Dancer2 requests...
Would it be possible to make "croak" work properly from within Dancer2 ?
At the moment, "croak" will show a stack-call coming from "Route.pm", and I would like to be able to have it point to my actual routing function (if that's somehow possible with un-named code refs and such).
Simple contrived example:
=======
sub foobar
{
croak "Something bad happened...";
}
get '/login' => sub {
foobar();
};
========
The croaked messages appears from:
===========
Something bad happened... at /usr/local/share/perl/5.12.4/Dancer/Route.pm line 240
===========
And the stack-track is:
=========
main in ./bin/app.pl l. 4
Dancer in /usr/local/share/perl/5.12.4/Dancer.pm l. 367
Dancer::Handler in /usr/local/share/perl/5.12.4/Dancer/Handler.pm l. 188
Dancer::Handler::Standalone in /usr/local/share/perl/5.12.4/Dancer/Handler/Standalone.pm l. 36
HTTP::Server::Simple in /usr/local/share/perl/5.12.4/HTTP/Server/Simple.pm l. 271
HTTP::Server::Simple in /usr/local/share/perl/5.12.4/HTTP/Server/Simple.pm l. 307
HTTP::Server::Simple in /usr/local/share/perl/5.12.4/HTTP/Server/Simple.pm l. 402
HTTP::Server::Simple::PSGI in /usr/local/share/perl/5.12.4/HTTP/Server/Simple/PSGI.pm l. 103
HTTP::Server::Simple::PSGI in /usr/local/share/perl/5.12.4/HTTP/Server/Simple/PSGI.pm l. 103
Dancer::Handler in /usr/local/share/perl/5.12.4/Dancer/Handler.pm l. 111
Dancer::Handler in /usr/local/share/perl/5.12.4/Dancer/Handler.pm l. 72
Dancer::Handler in /usr/local/share/perl/5.12.4/Dancer/Handler.pm l. 93
Dancer::Object in /usr/local/share/perl/5.12.4/Dancer/Object.pm l. 15
Dancer::Error in /usr/local/share/perl/5.12.4/Dancer/Error.pm l. 36
Dancer::Error in /usr/local/share/perl/5.12.4/Dancer/Error.pm l. 254
=========
Which makes it hard to debug...
So currently, all my subs use "die" instead of "croak", but this doesn't seem right (and also doesn't work with 3rd-party code that uses croak).
Comments are welcomed,
-gordon
More information about the Dancer-users
mailing list