[Catalyst] Catalyst::View::Mason and catching exceptions from DBIx::Class

Adam Sjøgren adsj at novozymes.com
Tue Dec 16 10:47:10 GMT 2014

I am using Catalyst::View::Mason and enjoy it - but I have noticed one
flaw, if DBIx::Class throws an exception in one of my Mason components,
the error won't be caught by Catalyst's standard stuff (wrapping in
boxes and with extra info in debug mode, sending email or whatever I
have configured in production mode).

Instead the exception is displayed directly to the user in the browser.

The reason is this logic in Catalyst::View::Mason::process():

    if (blessed($output) && $output->isa('HTML::Mason::Exception')) {
      ... do $c->error ...


    return 1;

The problem is that when DBIx::Class dies, $output is an object, but of
type DBIx::Class::Exception - so the error path isn't taken.

One way to work around this, is to check on ref($output)=~/Exception/,
but there might be a better way.

Any ideas?

  Best regards,


                                                          Adam Sjøgren
                                                    adsj at novozymes.com

More information about the Catalyst mailing list