From: Graham Knop Date: Mon, 27 Feb 2017 10:10:52 +0000 (+0100) Subject: throw error for missing perl files X-Git-Tag: v0.29~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=commitdiff_plain;h=c63419999f2c029f35bfcd700ae196eb0a3a08fa throw error for missing perl files --- diff --git a/lib/Config/Any/Perl.pm b/lib/Config/Any/Perl.pm index ff27b12..3e27a17 100644 --- a/lib/Config/Any/Perl.pm +++ b/lib/Config/Any/Perl.pm @@ -55,7 +55,8 @@ sub load { # tainted. untaint for backwards compatibility. my ($cwd) = Cwd::cwd() =~ /\A(.*)\z/s; $content = do File::Spec->rel2abs($file, $cwd); - $exception = $@; + $exception = $@ || $! + if !defined $content; } die $exception if $exception; diff --git a/t/53-perl.t b/t/53-perl.t index cd61a1f..1c26ff4 100644 --- a/t/53-perl.t +++ b/t/53-perl.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 12; use Config::Any; use Config::Any::Perl; @@ -44,3 +44,17 @@ use Config::Any::Perl; ok( !$config, 'config load failed' ); ok( $@, "error thrown ($@)" ); } + +# test missing config +{ + my $file = 't/invalid/missing.pl'; + my $config; + my $loaded = eval { + $config = Config::Any::Perl->load( $file ); + 1; + }; + + ok( !$loaded, 'config load failed' ); + ok( !$config, 'config load failed' ); + ok( $@, "error thrown ($@)" ); +}