Skip to content

Instantly share code, notes, and snippets.

@arodland
Created September 23, 2009 00:57
Show Gist options
  • Save arodland/191603 to your computer and use it in GitHub Desktop.
Save arodland/191603 to your computer and use it in GitHub Desktop.
sub finalize_error {
my $c = shift;
my $show_dump = (defined $c->config->{show_debugging_info})
? $c->config->{show_debugging_info}
: $c->beta; # beta is another method my app has... you can guess what it does.
if ($show_dump) {
# Let Catalyst::Plugin::StackTrace do its thing for dev
return $c->maybe::next::method();
} else {
$c->res->status(500);
$c->res->content_type('text/html;charset=utf-8');
if (open my $fh, '<', $c->path_to('static', 'error.html')) {
$c->res->content_length(-s $fh);
$c->res->body($fh);
} else {
$c->res->body(<<'EOF');
<html>
<head>
<title>Error</title>
</head>
<body>
There was an error processing your request. Unfortunately, there was also an
error locating the error page. For assistance please call Customer Service
at (XXX) XXX-XXXX.
</body>
</html>
EOF
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment