[Catalyst] Trapping added errors with the correct caller

Robert Rothenberg robrwo at gmail.com
Thu Oct 11 15:54:10 GMT 2012


On 11/10/12 14:16 Bill Moseley wrote:
> 
> 
> On Thu, Oct 11, 2012 at 5:38 AM, Robert Rothenberg <robrwo at gmail.com
> <mailto: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) = @_;
> 
>         foreach my $arg (@args) {
>             if ($arg) {
> 
>                 $c->log->error($arg);
>             }
>         }
> 
> 
> Isn't that what finalize already does?

I am using a custom error page.

More importantly: I also want to know where the error was triggered, hence
my question about using Sub::Uplevel.




More information about the Catalyst mailing list