From: Florian Ragwitz Date: Sat, 3 Jan 2009 05:28:26 +0000 (+0000) Subject: Mention the offending class when reporting errors when processing inherited attributes. X-Git-Tag: 0.65~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=329c5dd4a07a2767060d2641b760fe2f735e4aec;p=gitmo%2FMoose.git Mention the offending class when reporting errors when processing inherited attributes. Also test for it. --- diff --git a/lib/Moose/Meta/Class.pm b/lib/Moose/Meta/Class.pm index 66a2f23..f0a0c24 100644 --- a/lib/Moose/Meta/Class.pm +++ b/lib/Moose/Meta/Class.pm @@ -514,7 +514,7 @@ sub _process_inherited_attribute { my ($self, $attr_name, %options) = @_; my $inherited_attr = $self->find_attribute_by_name($attr_name); (defined $inherited_attr) - || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from", data => $attr_name); + || $self->throw_error("Could not find an attribute by the name of '$attr_name' to inherit from in ${\$self->name}", data => $attr_name); if ($inherited_attr->isa('Moose::Meta::Attribute')) { return $inherited_attr->clone_and_inherit_options(%options); } diff --git a/t/020_attributes/009_attribute_inherited_slot_specs.t b/t/020_attributes/009_attribute_inherited_slot_specs.t index 7d84bfc..1c825d9 100644 --- a/t/020_attributes/009_attribute_inherited_slot_specs.t +++ b/t/020_attributes/009_attribute_inherited_slot_specs.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 82; +use Test::More tests => 83; use Test::Exception; @@ -100,6 +100,9 @@ use Test::Exception; ::dies_ok { has '+other_fail' => (weak_ref => 1); } '... cannot create an attribute with an illegal option'; + ::throws_ok { + has '+does_not_exist' => (isa => 'Str'); + } qr/in Bar/, '... cannot extend a non-existing attribute'; } my $foo = Foo->new;