First, fix confess() so it actually exists. I don't know how
Dave Rolsky [Mon, 22 Sep 2008 15:02:40 +0000 (15:02 +0000)]
nothingmuch planned to implement switchign between throw_error() and
confess() here though.

lib/Moose/Util/TypeConstraints.pm

index 39e2acf..d3d6dd7 100644 (file)
@@ -247,6 +247,13 @@ sub normalize_type_constraint_name {
     return $type_constraint_name;
 }
 
+sub _confess {
+    my $error = shift;
+
+    local $Carp::CarpLevel = $Carp::CarpLevel + 1;
+    Carp::confess($error);
+}
+
 ## --------------------------------------------------------
 ## exported functions ...
 ## --------------------------------------------------------
@@ -373,11 +380,13 @@ sub _create_type_constraint ($$$;$$) {
     if (defined $name) {
         my $type = $REGISTRY->get_type_constraint($name);
 
-        ($type->_package_defined_in eq $pkg_defined_in)
-            || confess ("The type constraint '$name' has already been created in "
-                       . $type->_package_defined_in . " and cannot be created again in "
-                       . $pkg_defined_in)
-                 if defined $type;
+        ( $type->_package_defined_in eq $pkg_defined_in )
+            || _confess(
+                  "The type constraint '$name' has already been created in "
+                . $type->_package_defined_in
+                . " and cannot be created again in "
+                . $pkg_defined_in )
+            if defined $type;
     }
 
     my $class = "Moose::Meta::TypeConstraint";
@@ -1034,17 +1043,6 @@ Adds C<$type> to the list of parameterizable types
 
 =back
 
-=head1 Error Management
-
-=over 4
-
-=item B<confess>
-
-If the caller is a Moose metaclass, use its L<Moose::Meta::Class/throw_error>
-routine, otherwise use L<Carp/confess>.
-
-=back
-
 =head2 Namespace Management
 
 =over 4