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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.