Hello, After reading the documentation on the 'send_error' function (https://metacpan.org/module/Dancer#send_error), I expected it to work without needing a return: i.e. get '/route1' => sub { send_error "route1 error"; return "value from route1"; }; but I found that i need to use a return with it, like: get '/route2' => sub { return send_error "route2 error"; return "value from route2"; }; Is this an error in documentation, my understanding of documentation or a bug with the software (if so I'll open a bug with test case). I'm using Dancer 1.3080 and I was able to replicate this in the dancer test suite with a new test case. Thanks, Lee
Hello It is the correct behavior. You ned a return. Quoting the documentation: "This will not cause your route handler to return immediately, so be careful that your route handler doesn't then override the error. You can avoid that by saying "return send_error(...)" instead." Cheers ambs On 13/12/2011 23:29, Lee Carmichael wrote:
Hello,
After reading the documentation on the 'send_error' function (https://metacpan.org/module/Dancer#send_error), I expected it to work without needing a return:
i.e.
get '/route1' => sub { send_error "route1 error"; return "value from route1"; };
but I found that i need to use a return with it, like:
get '/route2' => sub { return send_error "route2 error"; return "value from route2"; };
Is this an error in documentation, my understanding of documentation or a bug with the software (if so I'll open a bug with test case). I'm using Dancer 1.3080 and I was able to replicate this in the dancer test suite with a new test case.
Thanks,
Lee _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hi, Ambs : in the new versions, send_error immediatly exists the current route, so there is no need to use 'return'. Lee Carmichael : This new behaviour is available only in 1,3090, not in 1.3080. So I guess you just need to upgrade :) Let me know if it's still buggy. Cheers, dams On 14 December 2011 11:49, ambs <ambs+dancer@perl-hackers.net> wrote:
Hello
It is the correct behavior. You ned a return.
Quoting the documentation:
"This will not cause your route handler to return immediately, so be careful that your route handler doesn't then override the error. You can avoid that by saying "return send_error(...)" instead."
Cheers ambs
On 13/12/2011 23:29, Lee Carmichael wrote:
Hello,
After reading the documentation on the 'send_error' function (https://metacpan.org/module/Dancer#send_error), I expected it to work without needing a return:
i.e.
get '/route1' => sub { send_error "route1 error"; return "value from route1"; };
but I found that i need to use a return with it, like:
get '/route2' => sub { return send_error "route2 error"; return "value from route2"; };
Is this an error in documentation, my understanding of documentation or a bug with the software (if so I'll open a bug with test case). I'm using Dancer 1.3080 and I was able to replicate this in the dancer test suite with a new test case.
Thanks,
Lee _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
_______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Hi ambs and dams, Thanks for the info. On Wed, Dec 14, 2011 at 5:35 AM, damien krotkine <dkrotkine@gmail.com> wrote:
Lee Carmichael : This new behaviour is available only in 1,3090, not in 1.3080. So I guess you just need to upgrade :) Let me know if it's still buggy.
Upgrading is the key, I've found my test case works in 1.3090. It was a bit odd since the existing test also worked with die after send_error in 1.3080. FYI, here is my updates to t/06_helpers/05_send_error.t: <snip> get '/error2' => sub { send_error "FAIL"; return "something completely different"; }; response_status_is [GET => '/error'] => 500, "status is 500 on send_error"; response_content_like [GET => '/error'] => qr/FAIL/, "content of error is kept"; # test '/error2' response_status_is [ GET => '/error2' ] => 500, "status is 500 on send_error"; response_content_like [ GET => '/error2' ] => qr/FAIL/, "content of error is kept even with return"; Take Care, Lee
participants (3)
-
ambs -
damien krotkine -
Lee Carmichael