[Catalyst] Controller methods

Will Hawes info at whawes.co.uk
Mon Jan 16 22:36:31 CET 2006


I tracked down an error in my code today that was caused by accidentally 
returning an objectref (a DBIx::Class::ResultSet, but the type is 
probably unimportant) from one of my controller methods. The offending 
code was something along the lines of

sub myaction : Local {
   ...
   $self->fetch_objects( $c );
   # return 1; # <- this fixed it..
}

where fetch_objects() is the action I use to run all my CDBI/DBIC searches.

First, what are valid things to return for a controller action? IMO it 
would be very useful if Catalyst could warn()/die() if it gets something 
unexpected. This type of error would become much easier to debug.

Second, despite having used Carp::confess() to get an idea, I'm still a 
bit unclear about exactly what was happening to the 
DBIx::Class::ResultSet returned by my action. Its count() method seemed 
to be getting called from inside Catalyst. But why??? The first few 
lines returned by confess(), if anyone can shed any light on this, are:

Caught exception "Unable to ->count with a GROUP BY at 
C:/ActivePerl5.8.7.815/site/lib/DBIx/Class/ResultSet.pm line 284
	DBIx::Class::ResultSet::count('DBIx::Class::ResultSet=HASH(0x5659dc4)', 
'undef', '') called at C:/ActivePerl5.8.7.815/site/lib/Catalyst.pm line 915

eval {...} called at C:/ActivePerl5.8.7.815/site/lib/Catalyst.pm line 915

Catalyst::execute('My=HASH(0x55b12e8)', 'My::Controller::User', 
'Catalyst::Action=HASH(0x386b8cc)') called at 
C:/ActivePerl5.8.7.815/lib/NEXT.pm line 75

NEXT::AUTOLOAD('My=HASH(0x55b12e8)', 'My::Controller::User', 
'Catalyst::Action=HASH(0x386b8cc)') called at 
C:/ActivePerl5.8.7.815/site/lib/Catalyst/Plugin/StackTrace.pm line 61

Catalyst::Plugin::StackTrace::execute('My=HASH(0x55b12e8)', 
'My::Controller::User', 'Catalyst::Action=HASH(0x386b8cc)') called at 
C:/ActivePerl5.8.7.815/site/lib/Catalyst/Action.pm line 43

Catalyst::Action::execute('Catalyst::Action=HASH(0x386b8cc)', 
'My=HASH(0x55b12e8)') called at 
C:/ActivePerl5.8.7.815/site/lib/Catalyst/Base.pm line 46

Catalyst::Base::_ACTION('My::Controller::User=HASH(0x2aeca80)', 
'My=HASH(0x55b12e8)') called at 
C:/ActivePerl5.8.7.815/site/lib/Catalyst.pm line 915

eval {...} called at C:/ActivePerl5.8.7.815/site/lib/Catalyst.pm line 915



More information about the Catalyst mailing list