[Dancer-users] Dancer2 - feature change request

damien krotkine dkrotkine at gmail.com
Fri Oct 21 21:42:52 CEST 2011


Le 21 oct. 2011 à 21:18, Assaf Gordon <gordon at cshl.edu> a écrit :

> 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).

I have taken care of that while refactoring the Dancer exceptions.
Could you try the topic/exceptions3 branch from github? I've stolen
the Carp mechanism and Replaced all croaks by Dancer Exceptions.
Verbosity of the stack trace can be setup with
$Dancer::Exception::verbose.

So when that branch is merged, it'll be fixed in dancer 1 :)

dams


>
> 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
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users


More information about the Dancer-users mailing list