[Catalyst] Re: Perl::Rails?

Brandon Black blblack at gmail.com
Sat Dec 10 00:17:40 CET 2005


On 12/9/05, Brandon Black <blblack at gmail.com> wrote:
> On 12/9/05, phaylon <phaylon at dunkelheit.at> wrote:
> > Hi there,
> >
> > Brandon Black said:
> > >
> > > If my controller code uses a random CPAN module, and that module does
> > > a "die 'foo';" somewhere inside itself, Catalyst says:
> > >
> > > [Fri Dec  9 15:37:06 2005] [catalyst] [error] Caught exception "foo at
> > > /path/to/Module.pm line 345"
> > >
> > > But does not provide stack context for what part of my controller code
> > > I was in when this error occured.
> > >
> >
> > How about this one, it's kind of a hack (since I haven't asked a core
> > developer how fixed error's behaviour is) but it is a start:
> >
> >   use NEXT;
> >
> >   sub error {
> >     my ( $c, @args ) = @_;
> >     if ( $args[0] and $args[0] =~ /^Caught exception/ ) {
> >         $args[0] = sprintf( 'Occured in /%s: ', $c->action )
> >           . $args[0];
> >     }
> >     return $c->NEXT::error( @args );
> >   }
> >
> > This gives me, if I place a "die 'Wooo';" in my App's login controller:
> >
> >   [Fri Dec  9 23:21:46 2005] [catalyst] [error] Occured in /login/login:
> >   Caught exception "Wooo at /home/p/perl/CX-Pandora/script/../lib/CX/
> >   Pandora/Controller/Login.pm line 9."
> >
> >
>
> That's a big improvement without the headaches of actual stack
> tracing, nice work.  I suspect there will be a little more to it than
> that in the end, since $c->error() may get called in other
> circumstances where $c->action isn't defined, and $c->action
> information becomes redundant when the actual death was in the
> controller code itself (and probably a host of other exceptional
> things I can't think of).
>

Oh, but it still doesn't neccesarily mean we were in that action code.
 It just means that the specified action was the intended action.  The
die could have occured in a view, or in a begin/auto/end block, etc. 
All of that can surely be determined from $c somehow as well though.

-- Brandon



More information about the Catalyst mailing list