LittleJack has asked for the wisdom of the Perl Monks concerning the following question:
I would like to have a different Catalyst error page for unexpected code errors. The default (non-debug) one only says "please come back later" in 11 European languages.
This is generated by hardcoded HTML HEREDOCs in finalize_error, which is an internal method.
Obviously the worst thing to do would be to hack into that code inside Catalyst::Engine and the best thing to do would probably be to use this: https://metacpan.org/pod/Catalyst::Plugin::CustomErrorMessage, but I'm curious. Should I have been able to hack my own finalize_error method into Catalyst?
I tried adding my own raw output code to the main .pm file for my site (the one which has use Catalyst in it) along the lines of
but the browser didn't output anything.print "Content-type: text/html\n\n<p>error</p>";
Then I tried adding my own hacked version of the proper internal method, along the lines of:
sub finalize_error { my ( $self, $c ) = @_; $c->res->content_type('text/html; charset=utf-8'); $c->res->body( '<p>error</p>' ); $c->res->status(500); }
But it told me $c was undefined.
Should I have been able to do this, and if so how and where?
TIA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Over-riding Catalyst's finalize_error method
by Your Mother (Archbishop) on May 17, 2021 at 02:33 UTC |