I sometimes use exception objects because catching exceptions based on class is less fragile than catching exceptions based on examining the error message.
if ($@) { # Fragile. if ($@ =~ /My error message/) { ... } else { die $@ } # Robust. if (blessed($@) and $@->isa("MyError")) { ... } else { die $@ } }
In reply to Re: Do you use an exception class in your Perl programs? Why or why not?
by creamygoodness
in thread Do you use an exception class in your Perl programs? Why or why not?
by TGI
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |