From: Shawn M Moore Date: Fri, 26 Jun 2009 15:32:05 +0000 (-0400) Subject: Include the class name in the method-less attribute message X-Git-Tag: 0.85~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f4450f37bd7be4b9a021345674ef4a0b7a95b04;p=gitmo%2FMoose.git Include the class name in the method-less attribute message --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 59ec385..25b94cb 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -562,7 +562,9 @@ sub install_accessors { || ($self->_is_metadata || '') eq 'bare' ) { Carp::cluck( - 'Attribute (' . $self->name . ') has no associated methods' + 'Attribute (' . $self->name . ') of class ' + . $self->associated_class->name + . ' has no associated methods' . ' (did you mean to provide an "is" argument?)' . "\n" ) diff --git a/t/020_attributes/026_attribute_without_any_methods.t b/t/020_attributes/026_attribute_without_any_methods.t index 5f0ba66..e932718 100644 --- a/t/020_attributes/026_attribute_without_any_methods.t +++ b/t/020_attributes/026_attribute_without_any_methods.t @@ -8,13 +8,13 @@ use Test::More tests => 2; use Moose (); use Moose::Meta::Class; -my $meta = Moose::Meta::Class->create_anon_class; +my $meta = Moose::Meta::Class->create('Banana'); my $warn; $SIG{__WARN__} = sub { $warn = "@_" }; $meta->add_attribute('foo'); -like $warn, qr/Attribute \(foo\) has no associated methods/, +like $warn, qr/Attribute \(foo\) of class Banana has no associated methods/, 'correct error message'; $warn = '';