[Catalyst] Controller methods

Will Hawes info at whawes.co.uk
Tue Jan 17 13:56:07 CET 2006


Matt S Trout wrote:
> On Tue, Jan 17, 2006 at 08:53:25AM +0000, Will Hawes wrote:
>> Matt S Trout wrote:
>>> On Mon, Jan 16, 2006 at 09:36:31PM +0000, Will Hawes wrote:
>>>> 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.
>>> Arbitrary things should normally be acceptable return values so that they
>>> can be returned by ->forward.
>> Does this mean completely arbitrary things, or just Catalyst components 
>> (which could be checked for)? Sorry if that's a dumb question but I'm 
>> trying to think of other types of object that are used with forward().
> 
> Not used with, returned from. There's a difference :)
> 
> sub foo :Private {
>   my ($self, $c) = @_;
>   ...
>   return $some_random_thing;
> }
> 

That's what I meant, in a rather-crap-use-of-English kind of way :)



More information about the Catalyst mailing list