dgaramond2 has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying out the Error module. The doc says:
catch CLASS with BLOCK: This clause will cause all errors that satisfy "$err->isa(CLASS)" to be caught and handled by evaluating "BLOCK". "BLOCK" will be passed two arguments. The first will be the error being thrown. The second is a reference to a scalar variable. If this variable is set by the catch block then, on return from the catch block, try will continue processing as if the catch block was never found.Now, is it possible to continue to the point right after the exception was originally thrown, while still have the exception handled first?
use Error qw(:try);
sub foo {
throw Error::Simple \-text => "oops";
print "1\n";
}
try {
foo();
}
catch Error::Simple with {
my ($err, $cont) = @_;
print "2\n";
$$cont = 1;
};
I want both print statements to print. If I don't surround the throw(), only "2" is printed. If I do, only "1" is printed.
Imagine the old DOS' "abort, retry, continue" scenario.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can we continue after an exception?
by GrandFather (Saint) on May 31, 2007 at 04:24 UTC | |
|
Re: Can we continue after an exception?
by perrin (Chancellor) on May 31, 2007 at 04:42 UTC | |
by dgaramond2 (Monk) on May 31, 2007 at 08:05 UTC | |
by clinton (Priest) on May 31, 2007 at 15:08 UTC | |
by perrin (Chancellor) on May 31, 2007 at 14:23 UTC | |
|
Re: Can we continue after an exception?
by educated_foo (Vicar) on May 31, 2007 at 06:38 UTC |