[Catalyst] C::P::StackTrace eats template exceptions?

Christopher H. Laco claco at chrislaco.com
Sat Jul 22 03:32:37 CEST 2006


Justin Guenther wrote:
> Just so nobody thinks this is getting ignored, I'm working on fixing it but
> the problem runs deeper than it would initially appear. C::P::StackTrace
> does its magic by having a localized $SIG{__DIE__} in the extended execute()
> method. It collects a Devel::StackTrace object and saves it for use in the
> finalize_error phase, which renders the error and makes it look pretty.
> 
> The problem is that with overriding $SIG{__DIE__}, _any_ exception,
> including ones caught by an eval{} block, are caught by the signal handler.
> This can be avoided by having `local $SIG{__DIE__}' and `local $@' in scope
> with the eval, but this is a messy workaround. (this is how the ACL plugin
> fixed the issue)
> 
> In this particular case, Template::Toolkit uses exception objects, which
> seem to get completely eaten somewhere between getting thrown and caught by
> eval{}. The $@ variable is the empty string, in this case, and it's
> completely impossible to tell if there is an exception or not.
> 
> I'm still working on this, but if anyone wants to check out the code in the
> C::P::StackTrace repository and step the perl debugger through the failing
> testcase I committed, it'd be a big help to get some more sets of eyes on
> this. If you can figure out where and why the $@ variable is being set to ''
> on object exceptions, you get a cookie!

I think I have a side-case for this. I'm running StackTrace 0.05 and
working on a Model which uses Handel. The very minute I load handel (use
Handel::Cart), and exceptions it throws (via Error) are displayed on the
first request in the debug screen.

The 2nd+ requests to the same page, method, throwing the same exception,
the error appears in the top message/error debug box, but the entire
stack trace output is missing.

I suspect this is the same issue, my use of Error, and it's DIE handlers
in there.

Not loading Handel, or not loading Error within, relieves the problem.

For the curious, the model is not more than:

> package Catalyst::Model::Handel::Cart;
> use strict;
> use warnings;
> use Scalar::Util qw/blessed/;
> use Class::Inspector;
> use Catalyst::Exception;
> use base qw/Catalyst::Model Class::Accessor::Grouped/;
> 
> __PACKAGE__->mk_group_accessors('inherited', qw/cart_class connection_info/);
> 
> sub COMPONENT {
>     my $self = shift->SUPER::new(@_);
>     my $cart_class = $self->cart_class || 'Handel::Cart';
>     if (!Class::Inspector->loaded($cart_class)) {
>         eval "use $cart_class";
>         if ($@) {
>             die "Could not load cart class $cart_class: $@";
>         } else {
>             $self->cart_class($cart_class);
>         };
>     };
>     $self->cart_class->storage->connection_info($self->connection_info);
> 
>     return $self;
> };
> 
> sub new {
>     return shift->cart_class->new(@_);
> };
> 
> 1;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/catalyst/attachments/20060721/2869b7d1/attachment.pgp 


More information about the Catalyst mailing list