Re: Aggressive exception handler making extra work for itself.
Dave Rolsky <[email protected]> Tue, 3 Apr 2007 18:08:45 -0500 (CDT)
| Newsgroups | gmane.comp.web.mason.devel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2 Apr 2007, Jonathan Swartz wrote:
> For Mason's purposes, we would need to be able to turn on/off stack traces in
> a dynamically scoped way (e.g. by setting an Exception::Class package var),
> since we want all errors that occur inside the request to convert to an
> Exception::Class object, and error_mode can change on a per-request basis.
There's a class data method Trace() that right now is turned on for all
Mason exceptions. It'd certainly be easy enough to turn that off for abort
& decline exceptions.
However, there is another problem, which is that Mason catches _all_
exceptions and passes them to
HTML::Mason::Exceptions::rethrow_exception(). This function will turn a
non-object exception into a HTML::Mason::Exception object, complete with
stack trace.
This behavior is useful when we're catching a real runtime error in a
component, because this lets us generate the pretty error pages. However,
if a component calls code that uses eval blocks internally (as many CPAN
modules do) then it's a huge waste.
The problem is that there's no way to distinguish between errors we want
to catch and those we don't. Ideally, every time a piece used an eval
block it would localize $SIG{__DIE__} in the block or something like that.
So the hacky workaround I came up with was to only set Mason's
$SIG{__DIE__} handler when the error mode is "output".
-dave
/*===================================================
VegGuide.Org www.BookIRead.com
Your guide to all that's veg. My book blog
===================================================*/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV