Since catch is invoked after the delocalization the previous value of $@
(whether meaningful or not) should still be available.
sub { ... }
+Inside the catch block the previous value of C<$@> is still available for use.
+This value may or may not be meaningful depending on what happenned before the
+C<try>, but it might be a good idea to preserve it in an error stack.
+
=back
=head1 BACKGROUND
use strict;
#use warnings;
-use Test::More tests => 21;
+use Test::More tests => 22;
BEGIN { use_ok 'Try::Tiny' };
}
{
- my $caught;
+ my ( $caught, $prev );
{
local $@;
}
} catch {
$caught = $_;
+ $prev = $@;
}
}
is_deeply( $caught, { prev => "bar\n" }, 'previous value of $@ available for capture' );
+ is( $prev, "bar\n", 'previous value of $@ also available in catch block' );
}