I completely agree, eval-die is flexible enough for most use. Is there any advantage with hierarchical exceptions which is worth the addition code and modules?
The original problem can be written as:
use warnings; use strict; use 5.0100; eval { print 10/0; # equivalent to: die "Illegal division by zero"; }; if($@) { if($@ =~ /Illegal division by zero/) { print "I feel funny\n"; exit; } else { die $@; } } # No exception thrown. print "What do you know, Perl can divide by zero.\n";
Updated: this code doesn't work properly before Perl 5.10, so I added a 'use' statement to stop it.
In reply to Re^2: Catching a 'division by zero' error with Exception::Class
by ggvaidya
in thread Catching a 'division by zero' error with Exception::Class
by baurel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |