To "fix" this problem for Class::Delegation version 1.06 (the highest currently available on CPAN.org right now) requires installing an autoload handler into the appropriate slot. In this case because the wrapper:: class delegates I'd install AUTOLOAD into that package. My current fix is to just rethrow $@ which appears to be the fix.
This is a problem because this behaviour isn't documented - I had to read the source code to understand it. It turns out that C::D looks for a pre-existing AUTOLOAD function and if it isn't present then it installs a function which croaks with the message "Could not delegate %s". This just overrides C::D's default autohandler.
sub wrapper::AUTOLOAD { # See http://www.perlmonks.org/index.pl?node_id=265697 # "Class::Delegation is incompatible with exceptions?" for # discussion of this function and why it is needed to get C::D # to support exceptions properly. if ($@ and not $@ =~ m{ Class\WDelegation\.pm\s+line\s+\d+.$ }xm) { die $@; } Carp::confess( "Could not delegate " . $AUTOLOAD ); }
In reply to Solved! Re: Class::Delegation *is* compatible with exceptions?
by diotalevi
in thread Class::Delegation is incompatible with exceptions?
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |