On Mon, Aug 14, 2000 at 10:56:36AM -0500, Jonathan Scott Duff wrote:
> On Mon, Aug 14, 2000 at 04:09:41AM -0600, Tony Olekshy wrote:
> > $@->CanFoo is an example of semantics that determines whether or
> > not the exception is caught; stringification may be an example
> > of semantics that comes into play when an exception is caught.
>
> Ah, this is why I started asking I guess. Some people were proposing
> a try/catch like the following:
>
> try { }
> catch SomeException { }
> catch SomeOtherException { }
> finally { }
>
> which seems to only catch exceptions based on name.
Yes, but an exception has multiple names as it is a class name
and you perform ->isa(name)
> Which implies to
> me that, for exceptions to have useful semantics, they'd have to be
> rethrown after they're caught. I like the following, but it would
> also seem that exceptions that aren't handled here would have to be
> rethrown so that an upstream catch could handle them.
>
> try { }
> catch { # ALL exceptions
> switch ($@) {
> case ^_->name eq 'IO' { ... }
> case ^_->canFoo { ... }
> throw $@; # No cases matched, rethrow
> }
> }
> finally { }
This is always an option for the programmer.
Graham.