[Catalyst] How to manage error 404
Marcello
m.romani at spinsoft.it
Tue Jun 28 11:10:17 CEST 2005
Albert Vila ha scritto:
> Hi all,
>
> I'm trying to build my first Catalyst Application, and I ran into the
> following problem:
> http://localhost:3000 serves my entry page
> http://localhost:3000/action serves the action I declared in my
> controller
>
> All is correct, but for each invalid request like localhost:3000/xyz,
> Catalyst uses the default method and serves the entry page instead of
> returning and 404 error page.
>
> Is there a way I can detect this invalid requests and return an error
> in my main module?
>
> Thanks
>
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst
>
A quick solutino I found to this problem is to have in my application
package a default action like this:
sub default : Private {
my ( $self, $c ) = @_;
$c->stash->{template} = 'invalid_request';
$c->req->action(undef);
}
Then in my 'root' directory, I have a template named 'invalid_request'
which says something like "You requested an invalid action." in an
error-like style.
Marcello
More information about the Catalyst
mailing list