use strict;
use warnings;
-use Carp 'confess';
+use Carp ();
use Scalar::Util 'blessed';
use Sub::Exporter;
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 {
=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