You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by THC Soft <th...@snafu.de> on 2002/08/28 09:00:24 UTC

[Q] Exception Handling

Hi all,

I usually receive just the digest mails and don't take part in the
discussions, so I'm maybe new to the list. I studied mod_perl guide,
grepped through my archives, visited search.cpan and even asked some
perlmonks, but couldn't find an answer to my problem. Here it is:

I have a content handler, which calls another module for translating
perl sources into valid html code. As this results in various nested
eval blocks, and each of these blocks will possibly die or warn for some
reason, I like to have a stacktrace through the eval{}s being reported
to the client in error cases, something like:

A mystic Perl error in some context
 at /var/www/html/test/t3.html line 8
 at /var/www/html/test/t2.html line 2
 at /var/www/html/test/t1.html line 889

(Please believe me: Carp is for special reasons *not* the answer)

If I understand the mod_perl guide (pp. 70-73) right, the solution will
be in an Exception class, overriding the CORE::die function. Well, but
if my translation module implemented that class, and Exception.pm
finally CORE::die()s, what about the content handler? Let's say the
translator dies with a "well formed" stacktrace, how can I get this to
the browser? Is it possible to override CORE::die twice? In the "inner
loop", the translating module, and again by the content handler? Would
Exporter->export_to_level be a way out? Or the Exception class being
used by the translator, while the content handler simply uses CGI::Carp
qw(fatals_to_browser) ? (If the content handler used the Exception
class, this one would have to interfere with values it cannot know.) Or
is there actually no problem at all, and I've just lost my way?

I hope I could make clear what I mean, my English must read awful for
native readers. Anyway, if you got a clue, or just an address where I
could dig a little deeper...

Thanx a lot in advance
regards
Martin