error handling for page metadata caching
Matt S Trout [Sat, 16 Jul 2011 20:20:47 +0000 (20:20 +0000)]
lib/SCSite/PageSet.pm

index 82c1e30..60a2a62 100644 (file)
@@ -54,16 +54,20 @@ sub _inflate {
   my $cache = io($cache_name);
   if (-f $cache_name) {
     if ($cache->mtime >= $io->mtime) {
-      return $self->_new_page($path, $self->_json->decode($cache->all));
+      return try {
+        $self->_new_page($path, $self->_json->decode($cache->all));
+      } catch {
+        die "Error inflating ${path} from cache: $_\n";
+      }
     }
   }
   my $raw = $io->all;
   try {
     my $extracted = $self->${\"_extract_from_${type}"}($raw);
-    $cache->print($self->_json->encode($extracted));
+    try { $cache->print($self->_json->encode($extracted)); };
     $self->_new_page($path, $extracted);
   } catch {
-    die "Error inflating ${path} as ${type}: $_\n\nData was: ${raw}";
+    die "Error inflating ${path} as ${type}: $_\n";
   }
 }