]> git.vpit.fr Git - perl/modules/Variable-Magic.git/blobdiff - lib/Variable/Magic.pm
Correctly propagate exceptions from _wizard()
[perl/modules/Variable-Magic.git] / lib / Variable / Magic.pm
index 5c049322588e47cd50db032e14a8a01083420c68..19badb0e5ab9eaf109cf1f15cbd03d31726efe9f 100644 (file)
@@ -300,18 +300,26 @@ sub wizard {
  }
 
  my %opts = @_;
+
  my @keys = qw/data op_info get set len clear free/;
  push @keys, 'copy'  if MGf_COPY;
  push @keys, 'dup'   if MGf_DUP;
  push @keys, 'local' if MGf_LOCAL;
  push @keys, qw/fetch store exists delete copy_key/ if VMG_UVAR;
- my $ret = eval { _wizard(map $opts{$_}, @keys) };
- if (my $err = $@) {
+
+ my ($wiz, $err);
+ {
+  local $@;
+  $wiz = eval { _wizard(map $opts{$_}, @keys) };
+  $err = $@;
+ }
+ if ($err) {
   $err =~ s/\sat\s+.*?\n//;
   require Carp;
   Carp::croak($err);
  }
- return $ret;
+
+ return $wiz;
 }
 
 =head2 C<cast>