From: Yuval Kogman Date: Tue, 1 Jul 2008 10:17:07 +0000 (+0000) Subject: add error checking for the return value of get_config_from_file X-Git-Tag: 0.03~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=870afbfa171c89e9e1c7e5d2421c8628fa9821c0;p=gitmo%2FMooseX-ConfigFromFile.git add error checking for the return value of get_config_from_file --- diff --git a/lib/MooseX/ConfigFromFile.pm b/lib/MooseX/ConfigFromFile.pm index 57e6f5b..e6b7d44 100644 --- a/lib/MooseX/ConfigFromFile.pm +++ b/lib/MooseX/ConfigFromFile.pm @@ -5,6 +5,8 @@ use MooseX::Types::Path::Class qw( File ); our $VERSION = '0.02'; +use Carp qw(croak); + requires 'get_config_from_file'; has configfile => ( @@ -28,7 +30,13 @@ sub new_with_config { } if(defined $configfile) { - %opts = (%{$class->get_config_from_file($configfile)}, %opts); + my $hash = $class->get_config_from_file($configfile); + + no warnings 'uninitialized'; + croak "get_config_from_file($configfile) did not return a hash (got $hash)" + unless ref $hash eq 'HASH'; + + %opts = (%$hash, %opts); } $class->new(%opts);