From: Shawn M Moore Date: Thu, 14 Jun 2012 19:07:29 +0000 (-0500) Subject: Ship throw off into Moose::Util X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=883c60be76090fdc542dd6eabd29b2b47b6c82bc;p=gitmo%2FMoose.git Ship throw off into Moose::Util --- diff --git a/lib/Moose.pm b/lib/Moose.pm index b454797..871605a 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -46,31 +46,10 @@ sub throw_error { goto \&confess } -sub throw_exception { - shift; - - my %args; - if (@_ == 1) { - $args{message} = shift; - } - else { - %args = @_; - } - - my $roles = delete($args{roles}); - - my $metaclass = Moose::Meta::Class->create_anon_class( - superclasses => ['Throwable::Error'], - ($roles ? (roles => $roles) : ()), - ); - - $metaclass->name->throw(\%args); -} - sub extends { my $meta = shift; - Moose->throw_exception("Must derive at least one class") unless @_; + Moose::Util::throw("Must derive at least one class") unless @_; # this checks the metaclass to make sure # it is correct, sometimes it can get out diff --git a/lib/Moose/Util.pm b/lib/Moose/Util.pm index 09803d4..967ad59 100644 --- a/lib/Moose/Util.pm +++ b/lib/Moose/Util.pm @@ -29,6 +29,7 @@ my @exports = qw[ english_list meta_attribute_alias meta_class_alias + throw ]; Sub::Exporter::setup_exporter({ @@ -470,6 +471,26 @@ sub _is_role_only_subclass { return 1; } +sub throw { + my %args; + if (@_ == 1) { + $args{message} = shift; + } + else { + %args = @_; + } + + my $roles = delete($args{roles}); + + my $metaclass = Moose::Meta::Class->create_anon_class( + superclasses => ['Throwable::Error'], + ($roles ? (roles => $roles) : ()), + ); + + $metaclass->name->throw(\%args); +} + + 1; # ABSTRACT: Utilities for working with Moose classes