From: phaylon Date: Wed, 8 Aug 2007 19:08:15 +0000 (+0000) Subject: clearer error message for missing type info; coercion handler only exported when... X-Git-Tag: 0.06~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types.git;a=commitdiff_plain;h=9563f55e99998c6618453988ccba898bc5613192 clearer error message for missing type info; coercion handler only exported when type object exists --- diff --git a/Changes b/Changes index 35e097c..97ad73a 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ 0.03 ... - Minor POD typo correction + - Added some error messages for wrong type names + - Coercion handler not exported without type object 0.02 Wed Aug 8 20:33:42 CEST 2007 - Changed declaration to croak when it sees '::' in a typename diff --git a/lib/MooseX/Types/Base.pm b/lib/MooseX/Types/Base.pm index 63d9cee..f5d32b7 100644 --- a/lib/MooseX/Types/Base.pm +++ b/lib/MooseX/Types/Base.pm @@ -10,7 +10,7 @@ MooseX::Types::Base - Type library base class #use strict; use Sub::Install qw( install_sub ); -use Carp qw( croak ); +use Carp::Clan qw( ^MooseX::Types ); use MooseX::Types::Util qw( filter_tags ); use Moose::Util::TypeConstraints; use Moose; @@ -75,7 +75,8 @@ sub export_type_into { my ($class, $target, $type, $undef_msg, %args) = @_; # the real type name and its type object - my $full = $class->get_type($type); + my $full = $class->get_type($type) + or croak "No fully qualified type name stored for '$type'"; my $tobj = find_type_constraint($full); # a possible wrapper around library functionality @@ -97,7 +98,7 @@ sub export_type_into { # only install to_Type coercion handler if type can coerce # or if we want to provide them anyway, e.g. declarations - if ($args{ -full } or $tobj->has_coercion) { + if ($args{ -full } or $tobj and $tobj->has_coercion) { # install to_Type coercion handler install_sub({