From: Tomas Doran Date: Thu, 27 Aug 2009 00:37:42 +0000 (+0100) Subject: Fix RT#47766 X-Git-Tag: 0.21~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c379a5cff8517fd7710698d9177c589bbe899b3;p=gitmo%2FMooseX-Getopt.git Fix RT#47766 --- diff --git a/ChangeLog b/ChangeLog index 5c800d9..aa7ab45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,9 +3,11 @@ Revision history for Perl extension MooseX-Getopt * MooseX::Getopt - Enable and document the argv parameter to the constructor. - Applied patches in RT43200 and RT43255 + - Applied patch from RT#47766 to not die if SimpleConfig cannot find the + default config file name. 0.20 Wed. July 9 2009 - ~ fix MANIFEST.SKIP to avoid double-packaging + - fix MANIFEST.SKIP to avoid double-packaging 0.19 Wed. July 8 2009 * MooseX::Getopt diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 0321f62..6c1100c 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -31,9 +31,16 @@ sub new_with_options { if(!defined $configfile) { my $cfmeta = $class->meta->find_attribute_by_name('configfile'); $configfile = $cfmeta->default if $cfmeta->has_default; + if (defined $configfile) { + $config_from_file = eval { + $class->get_config_from_file($configfile); + }; + if ($@) { + die $@ unless $@ =~ /Specified configfile '\Q$configfile\E' does not exist/; + } + } } - - if(defined $configfile) { + else { $config_from_file = $class->get_config_from_file($configfile); } }