use Devel::PartialDump to dump tc failures, if possible
[gitmo/Moose.git] / lib / Moose / Meta / TypeConstraint.pm
index c9fb6ad..f85cffb 100644 (file)
@@ -12,13 +12,10 @@ use overload '0+'     => sub { refaddr(shift) }, # id an object
 
 use Scalar::Util qw(blessed refaddr);
 use Sub::Name qw(subname);
+use Try::Tiny;
 
 use base qw(Class::MOP::Object);
 
-our $VERSION   = '1.17';
-$VERSION = eval $VERSION;
-our $AUTHORITY = 'cpan:STEVAN';
-
 __PACKAGE__->meta->add_attribute('name'       => (reader => 'name'));
 __PACKAGE__->meta->add_attribute('parent'     => (
     reader    => 'parent',
@@ -142,7 +139,13 @@ sub get_message {
         return $msg->($value);
     }
     else {
-        $value = (defined $value ? overload::StrVal($value) : 'undef');
+        # have to load it late like this, since it uses Moose itself
+        if (try { Class::MOP::load_class('Devel::PartialDump'); 1 }) {
+            $value = Devel::PartialDump->new->dump($value);
+        }
+        else {
+            $value = (defined $value ? overload::StrVal($value) : 'undef');
+        }
         return "Validation failed for '" . $self->name . "' with value $value";
     }
 }
@@ -321,14 +324,12 @@ sub create_child_type {
 
 1;
 
+# ABSTRACT: The Moose Type Constraint metaclass
+
 __END__
 
 =pod
 
-=head1 NAME
-
-Moose::Meta::TypeConstraint - The Moose Type Constraint metaclass
-
 =head1 DESCRIPTION
 
 This class represents a single type constraint. Moose's built-in type
@@ -402,7 +403,7 @@ C<equals> and C<is_subtype_of>.
 
 =item B<< $constraint->coerce($value) >>
 
-This will attempt to coerce the value to the type. If the type does
+This will attempt to coerce the value to the type. If the type does not
 have any defined coercions this will throw an error.
 
 If no coercion can produce a value matching C<$constraint>, the original
@@ -497,17 +498,4 @@ behavior and change how child types are created.
 
 See L<Moose/BUGS> for details on reporting bugs.
 
-=head1 AUTHOR
-
-Stevan Little E<lt>stevan@iinteractive.comE<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006-2010 by Infinity Interactive, Inc.
-
-L<http://www.iinteractive.com>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
 =cut