From: Stevan Little Date: Tue, 3 Jul 2007 21:02:30 +0000 (+0000) Subject: some helpful errors added X-Git-Tag: 0_06~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2482085fd5e5adf1d2aa6a37a7099c5fcd139f01;p=gitmo%2FMooseX-Getopt.git some helpful errors added --- diff --git a/ChangeLog b/ChangeLog index 1615caa..0ac67bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ Revision history for Perl extension MooseX-Getopt +0.05 + * MooseX::Getopt::OptionTypeMap + - added some checks to make sure that the type + constraints are found properly + 0.04 Tues. June 26, 2007 * MooseX::Getopt::OptionTypeMap - Added support for subtype constraint inference diff --git a/README b/README index a202abc..e91448f 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -MooseX::Getopt version 0.04 +MooseX::Getopt version 0.05 =========================== See the individual module documentation for more information diff --git a/lib/MooseX/Getopt.pm b/lib/MooseX/Getopt.pm index 6e5ead6..b9a5a1d 100644 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@ -7,7 +7,7 @@ use Getopt::Long (); use MooseX::Getopt::OptionTypeMap; use MooseX::Getopt::Meta::Attribute; -our $VERSION = '0.04'; +our $VERSION = '0.05'; our $AUTHORITY = 'cpan:STEVAN'; has ARGV => (is => 'rw', isa => 'ArrayRef'); diff --git a/lib/MooseX/Getopt/OptionTypeMap.pm b/lib/MooseX/Getopt/OptionTypeMap.pm index 10de77f..d56e479 100644 --- a/lib/MooseX/Getopt/OptionTypeMap.pm +++ b/lib/MooseX/Getopt/OptionTypeMap.pm @@ -4,7 +4,7 @@ package MooseX::Getopt::OptionTypeMap; use Moose 'confess'; use Moose::Util::TypeConstraints 'find_type_constraint'; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; my %option_type_map = ( @@ -21,6 +21,10 @@ sub has_option_type { return 1 if exists $option_type_map{$type_name}; my $current = find_type_constraint($type_name); + + (defined $current) + || confess "Could not find the type constraint for '$type_name'"; + while (my $parent = $current->parent) { return 1 if exists $option_type_map{$parent->name}; $current = $parent; @@ -31,10 +35,15 @@ sub has_option_type { sub get_option_type { my (undef, $type_name) = @_; + return $option_type_map{$type_name} if exists $option_type_map{$type_name}; my $current = find_type_constraint($type_name); + + (defined $current) + || confess "Could not find the type constraint for '$type_name'"; + while (my $parent = $current->parent) { return $option_type_map{$parent->name} if exists $option_type_map{$parent->name};