[Catalyst] How to manage error 404

Sebastian Riedel sri at oook.de
Tue Jun 28 12:56:46 CEST 2005


Am 28.06.2005 um 12:02 schrieb Chisel Wright:

> On Tue, Jun 28, 2005 at 11:52:23AM +0200, Albert Vila wrote:
>
>> I've I do this, how can I serve the default http://localhost:3000 ?
>>
>>
>>> sub default : Private {
>>>   my ( $self, $c ) = @_;
>>>     # use the default 404 page for the server
>>>   $c->res->status(404);
>>>     # make sure we have no action
>>>   $c->req->action(undef);
>>> }
>>>
>
>  sub default : Private {
>   my ( $self, $c ) = @_;
>
>   if ($c->req->action eq 'default') {
>    $c->forward($whatever);
>   }
>
>   $c->res->status(404);
>   $c->req->action(undef);
>  }
>
> perhaps?

I would just use:

     sub default : Private {
         my ( $self, $c, $something ) = @_;
         if ($something) {
             $c->res->status(404);
             # ...
         }
         else {
             # do something to handle root
         }
     }


--
sebastian




More information about the Catalyst mailing list