From: Matt S Trout Date: Sat, 16 Jul 2011 20:20:47 +0000 (+0000) Subject: error handling for page metadata caching X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4e3f5bd2d426b2e13697e53934ba6b35898f8980;p=scpubgit%2FSCS.git error handling for page metadata caching --- diff --git a/lib/SCSite/PageSet.pm b/lib/SCSite/PageSet.pm index 82c1e30..60a2a62 100644 --- a/lib/SCSite/PageSet.pm +++ b/lib/SCSite/PageSet.pm @@ -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"; } }