From: Russell Jenkins Date: Wed, 29 Apr 2015 00:49:14 +0000 (+1000) Subject: Capture file load errors for later use. X-Git-Tag: v0.26~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77afca3b1e24dee5bc1cecbc30fd3be9ea448889;p=p5sagit%2FConfig-Any.git Capture file load errors for later use. Localizing $@ also implies that any load error wasn't available outside of the do block. Instead of always returning 1, return $@ so any error is captured. The error is then rethrown if use_ext is enabled. Signed-off-by: Brian Cassidy --- diff --git a/lib/Config/Any.pm b/lib/Config/Any.pm index 7bdf2a6..2c2bc41 100644 --- a/lib/Config/Any.pm +++ b/lib/Config/Any.pm @@ -195,15 +195,15 @@ sub _load { next unless $loader->is_supported; $supported = 1; my @configs; - my $ok = do { + my $err = do { local $@; @configs = eval { $loader->load( $filename, $loader_args{ $loader } ); }; - 1; + $@; }; # fatal error if we used extension matching - croak "Error parsing $filename: $@" if !$ok and $use_ext_lut; - next if !$ok or !@configs; + croak "Error parsing $filename: $err" if $err and $use_ext_lut; + next if $err or !@configs; # post-process config with a filter callback if ( $args->{ filter } ) {