Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Catching a 'division by zero' error with Exception::Classby dreadpiratepeter (Priest) |
on Sep 15, 2008 at 14:36 UTC ( [id://711472]=note: print w/replies, xml ) | Need Help?? |
That won't work. the system dies with a division by 0 error when the 23/0 happens. The or clause that throws your error never occurs. You would have to either, throw the exception outside of the eval, or override the default die bahavior to throw the exception instead. Off the top of my head, I am not familiar enough with the exception classes to answer, but I'm sure there are other monks that will. UPDATE: Actually now that I think about it, your confusion occurs because Exception::Class is more for trapping application errors than for trapping underlying system errors. A better example for testing would be:
-pete "Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
In Section
Seekers of Perl Wisdom
|
|