At 02:56 AM 8/10/00 -0500, Jonathan Scott Duff wrote:
>Peter Scott writes:
> > try {
> > # fragile code
> > } catch Exception::IO with {
> > # handle IO exceptions
> > } catch Exception::Socket with {
> > # handle network exceptions
> > } otherwise {
> > # handle other exceptions
> > };
>
>What would the difference between that and this be?
>
> try {
> # fragile code
> } catch { # catch ALL exceptions
> switch ($EXCEPTION->name) {
> case IO { ... }
> case Socket { ... }
> }
> }
>
>The catch clause would catch all exceptions. The one thrown would be
>placed in a "global" $EXCEPTION variable.
TMTOWTDI, I guess. The exception variable comes into the catch block as
$_[0] in Error.pm. To catch all exceptions you'd just use an otherwise clause.
> > This is a strawman exception class hierarchy. The merits of this RFC
> > do not depend on this beign a good hierarchy, only on it being possible
> > to find a reasonable one.
>
>Is it really a hierarchy? Must it be? Your strawman looks more like
>an enumeration to me.
You're right, the places where I suggested subclassing wouldn't really be
subclasses, just an extra :: in the name to imply containership. Unless
the exception classes had some semantics I hadn't thought of, in which case
they could be inherited. Good point, I shall fix it in v2.
--
Peter Scott
Pacific Systems Design Technologies