[Catalyst] Trapping added errors with the correct caller

Bill Moseley moseley at hank.org
Thu Oct 11 13:16:54 GMT 2012

On Thu, Oct 11, 2012 at 5:38 AM, Robert Rothenberg <robrwo at gmail.com> wrote:

> I would like to trap every error added to $c->error() and log it, noting
> the
> caller (filename, line number) in the logs.
> I've not gotten Catalyst::Plugin::ErrorCatcher to work, so I wrote my own
> plugin that overrides $c->error with the following method:
>   use MRO::Compat;
>   use namespace::autoclean;
>   sub error {
>     my ($c, @args) =3D @_;
>     foreach my $arg (@args) {
>         if ($arg) {
>             $c->log->error($arg);
>         }
>     }

Isn't that what finalize already does?

I have a very old and out-dated plugin I use that wraps execute() and sets
__DIE__ and __WARN__ to catch those and uses Devel::StackTrace to add in a
stack trace.   Then I use log4perl to format and direct the messages.

I also use Moose's Throwable which includes a stack trace.

-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20121011/9e59a=

More information about the Catalyst mailing list