From: Hans Dieter Pearcey Date: Wed, 24 Jun 2009 20:27:01 +0000 (-0400) Subject: warn instead of dying X-Git-Tag: 0.84~40^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a46d86de42b016d9e562eac5dcdf5f59aee5afac;p=gitmo%2FMoose.git warn instead of dying --- diff --git a/Changes b/Changes index 6a7d3cb..03d33a7 100644 --- a/Changes +++ b/Changes @@ -4,7 +4,7 @@ for, noteworthy changes. 0.XX * Moose::Meta::Attribute - When adding an attribute to a metaclass, if the attribute has no - methods associated with, it will now throw an error. (hdp) + methods associated with, it will give a deprecation warning. (hdp) 0.83 Tue, Jun 23, 2009 * Moose::Meta::Class diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 7f76bc3..2673fc6 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -546,9 +546,10 @@ sub install_accessors { || @{ $self->associated_methods } || ($self->_is_metadata || '') eq 'bare' ) { - $self->throw_error( + Carp::cluck( 'Attribute (' . $self->name . ') has no associated methods' . ' (did you mean to provide an "is" argument?)' + . "\n" ) } return; diff --git a/t/020_attributes/026_attribute_without_any_methods.t b/t/020_attributes/026_attribute_without_any_methods.t index c6f1348..5f0ba66 100644 --- a/t/020_attributes/026_attribute_without_any_methods.t +++ b/t/020_attributes/026_attribute_without_any_methods.t @@ -10,13 +10,13 @@ use Moose::Meta::Class; my $meta = Moose::Meta::Class->create_anon_class; -#local $TODO = 'not implemented yet'; +my $warn; +$SIG{__WARN__} = sub { $warn = "@_" }; -eval { $meta->add_attribute('foo') }; -like $@, qr/Attribute \(foo\) has no associated methods/, +$meta->add_attribute('foo'); +like $warn, qr/Attribute \(foo\) has no associated methods/, 'correct error message'; -ok( - eval { $meta->add_attribute('bar', is => 'bare'); 1 }, - 'add attribute with no methods', -) or diag $@; +$warn = ''; +$meta->add_attribute('bar', is => 'bare'); +is $warn, '', 'add attribute with no methods and is => "bare"';