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

print "Content-type: text/html\n\n<p>error</p>";
but the browser didn't output anything.

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


In reply to Over-riding Catalyst's finalize_error method by LittleJack

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.