Catalyst::View::Mason and Exception objects

View: New views
1 Messages — Rating Filter:   Alert me  

Catalyst::View::Mason and Exception objects

by Stephen Clouse :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The following Mason template:

<%init>
die;
</%init>

results in a typical Catalyst error response.

This, on the other hand:

<%init>
DBIx::Class::Exception->throw('Foo');
</%init>

just gives a plain-text output, and the request is recorded as a success ($c->error is not set, finalize_error is not called, plugins like ErrorCatcher are never triggered).

The issue seems to lie here:

174    if (blessed($output) && $output->isa('HTML::Mason::Exception')) {
175        chomp $output;
176        my $error = qq/Couldn't render component "$component_path" - error was "$output"/;
177        $c->log->error($error);
178        $c->error($error);
179        return 0;
180    }

Since Mason does not wrap exception objects but simply re-throws them, the exception object gets here and bypasses this.

More interesting is that this actually appears to be intentional behavior -- the View::Mason distro actually tests for it in t/exception.t.  Any ideas on why it's handled this way and how to make it DWIM?

--
Stephen Clouse <stephenclouse@...>

_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/