Found the solution (see below). Puneet Kishor wrote:
Matthew Vickers wrote:
----- "Puneet Kishor"<punk.kish@gmail.com> wrote:
Completely foxed here. I have code like
get '/*?' => sub { .. debug "foo"; template $template, \%template_opts; debug "bar"; }
My development log shows
[10182] debug @0.051256> [hit #1] foo in /Users/punkish/Sites/punkish/lib/punkish.pm l. 255 [10182] debug @0.056021> [hit #1] bar in /Users/punkish/Sites/punkish/lib/punkish.pm l. 257
However, in my browser I get the dreaded "status code needs to be an integer greater than or equal to 100 at /usr/local/lib/perl5/site_perl/5.12.1/Plack/Middleware/StackTrace.pm line 27"
Any suggestions?
Is the return value of your route the return value from the debug call ?
Try:
my $response= template($template, \%template_opts); debug("bar"); return $response;
Even more bizarre, the following
my $response = template $template, \%template_opts; debug "response $response"; return $response;
dumps the correctly formatted and filled template in the development.log, but the browser still gets the error trace with the "status code... " error.
So, I upgraded from 1.2003 to 1.3003 (didn't even know that existed... wish Perl had something like the Mac OS X Sparkle auto-update framework). Now I get a much better message, not that cryptic and useless "status ... " message. Turns out, I had code like so my $year; while (my ($page_year) = $sth->fetchrow_array) { if ($year != $page_year) { and that triggered a { "error" : "Warning caught during route execution: Use of uninitialized value $year in numeric ne (!=) at /Users/punkish/Sites/punkish/lib/punkish.pm line 559.\n" } Well, I changed my $year declaration line to my $year = 0; and it all works. But, this shouldn't really cause a fatal error. Why is this kind of error causing the entire application to barf? There is no concept of typing in Perl, so why enforce it? Puneet.