[Catalyst] Error handling

Albert Vila avp at imente.com
Tue Oct 25 18:08:51 CEST 2005



Matt S Trout wrote:
> On Tue, Oct 25, 2005 at 05:10:50PM +0200, Albert Vila wrote:
>   
>> Sebastian Riedel wrote:
>>     
>>> Am 25.10.2005 um 16:27 schrieb Albert Vila:
>>>
>>>       
>>>> Matt S Trout wrote:
>>>>
>>>>         
>>>>> On Mon, Oct 24, 2005 at 07:06:46PM +0200, Albert Vila wrote:
>>>>>
>>>>>
>>>>>           
>>>>>> Hello,
>>>>>>
>>>>>> I have a problem trying to configure my catalyst application in 
>>>>>> order to do the error handling in the begin method.
>>>>>>
>>>>>> I have a controller with multiple functions, each function receives 
>>>>>> the same parameter, and I wanna check the parameter integrity in 
>>>>>> just one place.
>>>>>>
>>>>>>
>>>>>>             
>>>>> If you set $c->error in your 'sub begin' then dispatch should 
>>>>> short-circuit
>>>>> and jump straight to the end action afterwards.
>>>>>
>>>>>
>>>>>           
>>>> That's true, but catalyst shows the error screen instead of the 
>>>> template in the stash.
>>>>         
>>> Thats right, you have to clean $c->{error} when you handle them manually!
>>>
>>>       
>> There isn't a better approach to deal with this problem. Maybe modify 
>> the Dispatcher.pm in order to set a flag in the detach method and modify 
>> the dispatch method to check if this flag is on or off.
>>     
>
> What's wrong with
>
> sub MyApp::auto { my ($self, $c) = @_; return 0 if $c->stash->{myflag}; }
>
> and you just set $c->stash->{myflag} as appropriate?
>
> Or just use an auto action for this rather than begin, like everybody else
> does :)
>
>   
Thank you very much Matt, that is exactly what I was looking for. I 
didn't know the appropriate use of the auto method. I didn't check the 
docs, I apologize.

Albert




More information about the Catalyst mailing list