aboutsummaryrefslogtreecommitdiff
path: root/lib/File/Cache/Parsed.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/File/Cache/Parsed.pm')
-rw-r--r--lib/File/Cache/Parsed.pm10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/File/Cache/Parsed.pm b/lib/File/Cache/Parsed.pm
index 280dab7..a8a8e2e 100644
--- a/lib/File/Cache/Parsed.pm
+++ b/lib/File/Cache/Parsed.pm
@@ -6,6 +6,7 @@ use List::MoreUtils qw(firstidx);
use Cwd 'abs_path';
use Path::Class;
use Carp;
+use Try::Tiny;
sub new {
my ($class,%opts)=@_;
@@ -82,9 +83,7 @@ sub get {
return $self->{cache}{$filename} if exists $self->{cache}{$filename};
- my $contents=eval {file($filename)->slurp};
-
- return if $@;
+ my $contents=try {file($filename)->slurp} catch {return};
my $pp=first {$filename =~ m{$_->[0]}} @{$self->{parsers}};
if ($pp) {
@@ -110,12 +109,11 @@ sub put {
my $err;
my $ww=first {$filename =~ m{$_->[0]}} @{$self->{writers}};
if ($ww) {
- my $ret=eval {$ww->[1]->($filename,$contents)};
- unless ($@) {
+ my $ret=try {$ww->[1]->($filename,$contents)} catch {$err=$_};
+ unless ($err) {
$self->{cache}{$filename}=$contents;
return $ret;
}
- $err=$@;
}
if (!ref($contents)) {
my $pp=first {$filename =~ m{$_->[0]}} @{$self->{parsers}};