Pārlūkot izejas kodu

Fix #137 correctly: once more with feeling

George S. Baugh 5 gadi atpakaļ
vecāks
revīzija
0a3b94ac62
1 mainītis faili ar 6 papildinājumiem un 2 dzēšanām
  1. 6 2
      lib/Trog/Data/FlatFile.pm

+ 6 - 2
lib/Trog/Data/FlatFile.pm

@@ -47,12 +47,16 @@ sub read ($self, $query={}) {
     my @items;
     foreach my $item (@index) {
         next unless -f $item;
-        my $slurped = eval { File::Slurper::read_text($item) };
+        my $slurped = eval { File::Slurper::read_binary($item) };
         if (!$slurped) {
             print "Failed to Read $item:\n$@\n";
             next;
         }
-        my $parsed  = $parser->decode($slurped);
+        my $parsed  = eval { $parser->decode($slurped) };
+        if (!$parsed) {
+            print "JSON Decode error on $item:\n$@\n";
+            next;
+        }
 
         #XXX this imposes an inefficiency in itself, get() will filter uselessly again here
         my @filtered = $self->filter($query,@$parsed);