Ask Bjørn Hansen
2010-09-13 09:30:47 UTC
Somewhat related to the index.html post:
In my project that's now running on Plack/PSGI[1] I need to handle 404's more gracefully than they are by default. By default the 404s show up just as server errors.
Under apache the request handler uses _handle_error() to rethrow
sub _handle_error
{
my ($self, $err) = @_;
if (isa_mason_exception($err, 'TopLevelNotFound')) {
rethrow_exception $err;
...
... and I'm guessing this somehow gets turned into declining the request via the mod_perl API?
Anyway - what am I supposed to do to return something else in this case?
I'd be happy just returning a static string and flagging the request to set the status as 404; but ideally I'd like to be able to "restart" the request with a $error_404_url or run a bit of code to generate the response.
Any hints would be appreciated -- I stared at the code for almost an hour and got nowhere. It's been, ahem, a few years since I worked with Mason. :-)
- ask
[1] http://github.com/abh/HTML-Mason-PSGIHandler -- thanks to miyagawa.
In my project that's now running on Plack/PSGI[1] I need to handle 404's more gracefully than they are by default. By default the 404s show up just as server errors.
Under apache the request handler uses _handle_error() to rethrow
sub _handle_error
{
my ($self, $err) = @_;
if (isa_mason_exception($err, 'TopLevelNotFound')) {
rethrow_exception $err;
...
... and I'm guessing this somehow gets turned into declining the request via the mod_perl API?
Anyway - what am I supposed to do to return something else in this case?
I'd be happy just returning a static string and flagging the request to set the status as 404; but ideally I'd like to be able to "restart" the request with a $error_404_url or run a bit of code to generate the response.
Any hints would be appreciated -- I stared at the code for almost an hour and got nowhere. It's been, ahem, a few years since I worked with Mason. :-)
- ask
[1] http://github.com/abh/HTML-Mason-PSGIHandler -- thanks to miyagawa.
--
Ask Bjørn Hansen, http://askask.com/
Ask Bjørn Hansen, http://askask.com/