[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
Re: A common base exception object for Perl - RFC
"Redford, John" wrote:
> the point were the Exception is raised is explicitly NOT where the
> logic to handle the exception is located. What would be best is a way
> for:
> eval { ... die new Exception }
> if ( blessed($@) and $@->isa('Exception') ) { confess $@ }
> to generate a stack dump as-if the confess occurred where the exception
> was located. This would seem to require for 'die' to look at its argument
This is exactly what I have running here now (and in Graham's C<Error>
module).
In both cases, the exception creation code stuffs a stack trace into one
of its properties iff a global flag is set (to avoid the overhead of
walking the stack when not required).
Further, as I perform unnatural and forbidden acts witb
C<$SIG{__DIE__}>, I can write:
debugLevel 1; # sorry Tom :)
try {
die "foo";
} except {
$@->croak;
};
> if ( blessed($@) and $@->isa('Exception') ) { confess $@ }
Even without dodgy pseudo-SIG processing,
blessed $@ and $@->croak
should do. The whole point of all this is that if C<$@> isn't a string,
it's an Exception or a subclass thereof... (Anybody using a prior
exception system will already have code to handle it.)
> Personally, I would just not worry about it now; I'd rather see a basic
> module sooner than a do-everything module-suite later.
Well, quite. In any case, the definition of do-everything is an
attribute of any given programmer...
Pete
--
use Disclaimer::Standard; # Motorola GSM Software Factory
my $phone='+44 1793 564450'; # "'Not twisted,' Salzy once said of
my $fax='+44 1793 566918'; # her own passion, 'it is helical.
my $mobile='+44 7973 725120'; # That sounds better.'"
- References to:
-
"Redford, John" <John.Redford@fmr.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]