Darin McBride wrote:
On September 16, 2003 11:20 am, Steve Hay wrote:Couldn't you at least revert it to its old behaviour, seeing as you're not doing anything special with it?, e.g. my $body = eval { $autoload_mode ? $self->$rmeth($rm) : $self->$rmeth() }; die "Error executing run mode '$rm': $@" if $@ and ref($meth) eq 'CODE';That seems reasonable. However, I would suggest not going half-way here: my $body = eval { $autoload_mode ? $self->$rmeth($rm) : $self->$rmeth() }; if ( $@ ) { $self->my_die($rm, $@); return; # in case my_die returns } Then C::A could have a new method: sub my_die { my $self = shift; my ($rm, $@) = @_; die "Error executing run mode '$rm': $@"; } This would probably give you exactly what you want: your subclass of C::A could override my_die and you'd have exactly the exception object that you threw elsewhere. And you can handle it whatever way you want. [snip] How does the above my_die handle your expectations? It allows everyoneto use die normally, and gives you the exception handler you want. Meanwhile, it still gives everyone else a reasonable default handler. Or at least, the same default handler we have now ;-)
This would be a lot better for me, although still not perfect.In my case, I would probably override my_die() to simply rethrow the exception. The exception handler in my mod_perl handler that wraps the whole $app->run() call would then catch it and process it appropriately; the only problem is that the exception will be seen as having been thrown from the my_die() override rather than where it really came from.
Alternatively I could restructure things a bit and move the exception handling that is currently in my mod_perl handler down into the my_die() override itself. That might work out OK.
Actually, this idea is exactly what Thilo suggested in the thread that I mentioned previously (http://www.mail-archive.com/suppressed/msg00196.html), with cgiapp_exception() instead of my_die().
How about it, Jesse? There seem to be a few people wanting this.I'm not asking for exception handling in C::A itself. I just want it to allow me to do it myself! Surely it wasn't your intention for C::A to stand in the way of that?
Cheers,
- Steve
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed
Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.