From: Tomas Doran Date: Wed, 15 Apr 2009 13:57:36 +0000 (+0000) Subject: Clarify exception to finger the actual class which contains the dodgy COMPONENT method X-Git-Tag: 5.80001~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7490de2a2960943246d1eda490bde230384eb1be;p=catagits%2FCatalyst-Runtime.git Clarify exception to finger the actual class which contains the dodgy COMPONENT method --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index e60e1bb..284f815 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -2181,11 +2181,15 @@ sub setup_component { ); } - Catalyst::Exception->throw( - message => - qq/Couldn't instantiate component "$component", "COMPONENT() didn't return an object-like value"/ - ) unless blessed($instance); - + unless (blessed $instance) { + my $metaclass = Moose::Util::find_meta($component); + my $method_meta = $metaclass->find_method_by_name('COMPONENT'); + my $component_method_from = $method_meta->associated_metaclass->name; + Catalyst::Exception->throw( + message => + qq/Couldn't instantiate component "$component", COMPONENT() method (from $component_method_from) didn't return an object-like value./ + ); + } return $instance; }