From: Shawn M Moore Date: Tue, 10 Feb 2009 01:38:43 +0000 (+0000) Subject: Make some keyword errors use throw_error instead of croak since Moose::Exporter wraps... X-Git-Tag: 0.69~36 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2095e4ad1decf05ef4cf51df25e7590ec4024ab;p=gitmo%2FMoose.git Make some keyword errors use throw_error instead of croak since Moose::Exporter wraps keywords now --- diff --git a/Changes b/Changes index 0ea2895..dfe1f5e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension Moose + * Moose + - Make some keyword errors use throw_error instead of croak + since Moose::Exporter wraps keywords now (Sartak) + 0.68 Wed, February 4, 2009 * POD - Many spelling, typo, and formatting fixes by daxim. diff --git a/lib/Moose.pm b/lib/Moose.pm index 665765f..98c366b 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -11,7 +11,7 @@ $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; use Scalar::Util 'blessed'; -use Carp 'confess', 'croak', 'cluck'; +use Carp 'confess'; use Moose::Exporter; @@ -52,12 +52,12 @@ sub throw_error { sub extends { my $class = shift; - croak "Must derive at least one class" unless @_; + Moose->throw_error("Must derive at least one class") unless @_; my @supers = @_; foreach my $super (@supers) { Class::MOP::load_class($super); - croak "You cannot inherit from a Moose Role ($super)" + Moose->throw_error("You cannot inherit from a Moose Role ($super)") if $super->can('meta') && blessed $super->meta && $super->meta->isa('Moose::Meta::Role') @@ -80,7 +80,10 @@ sub with { sub has { my $class = shift; my $name = shift; - croak 'Usage: has \'name\' => ( key => value, ... )' if @_ == 1; + + Moose->throw_error('Usage: has \'name\' => ( key => value, ... )') + if @_ == 1; + my %options = ( definition_context => _caller_info(), @_ ); my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; Class::MOP::Class->initialize($class)->add_attribute( $_, %options ) for @$attrs;