Subject: | Exceptions in user code are not propogated correctly |
Any use of die() in user code is interpreted as a non-existant method by C::D's delegate() method. The attached patch merely rethrows $@ if it is true.
$w = wrapper->instance;
$w->table;
# Dies with the error "Could not delegate wrapper::table". This should die with
# the error "Some exception".
package wrapper;
sub instance {
return bless { schema => database->new() }, shift();
}
sub schema { $_[0]->{schema} }
use Class::Delegation
send => '-ALL',
to => 'schema';
package database;
sub new { bless {}, shift() }
sub table { $_[0]->column }
sub column { die "Some exception" }
--- Delegation.pm~ Mon Apr 22 23:20:23 2002
+++ Delegation.pm Fri Jun 13 11:22:45 2003
@@ -53,6 +53,7 @@
next DELEGATOR if exists $delegated->{$to[0]};
foreach my $as (@as) {
push @results, delegate($delegated,$wantarray,$invocant,$to[0],$as,\@args);
+ die $@ if $@;
}
}
elsif (@as==1) {
@@ -60,6 +61,7 @@
foreach my $to (@to) {
next if exists $delegated->{$to};
push @results, delegate($delegated,$wantarray,$invocant,$to,$as[0],\@args);
+ die $@ if $@;
}
}
else {
@@ -69,6 +71,7 @@
my $as = shift @as;
next if exists $delegated->{$to};
push @results, delegate($delegated,$wantarray,$invocant,$to,$as,\@args);
+ die $@ if $@;
}
}
}