From: Shawn M Moore Date: Sat, 26 Jan 2008 16:50:56 +0000 (+0000) Subject: Give an error message when a handles attribute's object is undefined, so it doesn... X-Git-Tag: 0_37~21 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=27f6e1e36de4494b1f641a4c4d468b64e9759542;p=gitmo%2FMoose.git Give an error message when a handles attribute's object is undefined, so it doesn't look like a Moose error --- diff --git a/lib/Moose/Meta/Attribute.pm b/lib/Moose/Meta/Attribute.pm index 50b23a8..960daf3 100644 --- a/lib/Moose/Meta/Attribute.pm +++ b/lib/Moose/Meta/Attribute.pm @@ -405,9 +405,10 @@ sub install_accessors { $associated_class->add_method($handle => subname $name, sub { my $proxy = (shift)->$accessor(); @_ = ($proxy, @_); - (defined $proxy) - || confess "Cannot delegate $handle to $method_to_call because " . - "the value of " . $self->name . " is not defined"; + + defined($proxy) + or confess "Undefined 'handles' for attribute '".$self->name."' for method '$name'."; + goto &{ $proxy->can($method_to_call) || return }; }); }