[Dancer-users] error stack does not include my application

Gabor Szabo szabgab at gmail.com
Fri Jun 10 17:36:51 CEST 2011


In a small application I was writing I had an error. The code looked like this:

use File::Slurp qw(read_file);

get '/' => sub {
    my $path = config->{appdir} . '/data.json';
    my $posts;
    if (-e $path) {
        $posts = from_json read_file $path ;
    }
    template 'index', { posts => $posts };
};

The problem was that read_file was called in LIST context instead of
SCALAR context
which made the JSON incorrect and passed strange parameters to the
from_json call.
I solved it now

BUT

This is the error I got from Dancer. This does not mention my code at
all. It jumps
from app.pl to Dancer.pm hich is not good IMHO.



Can't locate object method "   }
" via package "JSON" at C:/strawberry/perl/vendor/lib/JSON.pm line 164.

C:/strawberry/perl/vendor/lib/JSON.pm around line 164

161     if (@_ == 2 and ref $_[1] eq 'HASH') {
162         my $opt  = $_[1];
163         for my $method (keys %$opt) {
164             $json->$method( $opt->{$method} );
165         }
166     }
167

Stack

main in bin\app.pl l. 4
Dancer in C:/strawberry/perl/site/lib/Dancer.pm l. 352
Dancer::Handler in C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 179
Dancer::Handler::Standalone in
C:/strawberry/perl/site/lib/Dancer/Handler/Standalone.pm l. 36
HTTP::Server::Simple in C:/strawberry/perl/site/lib/HTTP/Server/Simple.pm l. 271
HTTP::Server::Simple in C:/strawberry/perl/site/lib/HTTP/Server/Simple.pm l. 307
HTTP::Server::Simple in C:/strawberry/perl/site/lib/HTTP/Server/Simple.pm l. 402
HTTP::Server::Simple::PSGI in
C:/strawberry/perl/site/lib/HTTP/Server/Simple/PSGI.pm l. 103
HTTP::Server::Simple::PSGI in
C:/strawberry/perl/site/lib/HTTP/Server/Simple/PSGI.pm l. 103
Dancer::Handler in C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 102
Dancer::Handler in C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 71
Dancer::Handler in C:/strawberry/perl/site/lib/Dancer/Handler.pm l. 87
Dancer::Object in C:/strawberry/perl/site/lib/Dancer/Object.pm l. 15
Dancer::Error in C:/strawberry/perl/site/lib/Dancer/Error.pm l. 34
Dancer::Error in C:/strawberry/perl/site/lib/Dancer/Error.pm l. 248


regards
   Gabor
   http://szabgab.com/


More information about the Dancer-users mailing list