From: Yuval Kogman Date: Mon, 23 Jun 2008 16:09:47 +0000 (+0000) Subject: Moose::Util::TypeConstraints confess X-Git-Tag: 0.58~54^2~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=998a8a25f9f00cf2b8f5e2ddd3089ab2a6cbfcb2;p=gitmo%2FMoose.git Moose::Util::TypeConstraints confess --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 51cfd79..adbb77c 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -4,7 +4,7 @@ package Moose::Util::TypeConstraints; use strict; use warnings; -use Carp 'confess'; +use Carp (); use Scalar::Util 'blessed'; use Sub::Exporter; @@ -101,6 +101,18 @@ sub unimport { my $REGISTRY = Moose::Meta::TypeConstraint::Registry->new; +sub confess { + my ($msg, @args) = @_; + + my $caller = caller(2); + if ( $caller->can("meta") and my $throw = $caller->meta->can("throw_error") ) { + goto $throw; + } else { + @_ = $msg; + goto &Carp::confess; + } +} + sub get_type_constraint_registry { $REGISTRY } sub list_all_type_constraints { keys %{$REGISTRY->type_constraints} } sub export_type_constraints_as_functions { @@ -1011,6 +1023,17 @@ Adds C<$type> to the list of parameterizable types =back +=head1 Error Management + +=over 4 + +=item B + +If the caller is a Moose metaclass, use its L +routine, otherwise use L. + +=back + =head2 Namespace Management =over 4