in reply to Re: Class::Delegation is incompatible with exceptions?
in thread Class::Delegation is incompatible with exceptions?

I altered my local copy to rethrow exceptions but I don't understand the problem domain well enough to know whether that is a valid thing to do or whether I have to be more careful.

For anyone that is interested, my alterations:

# diff -u Delegation.pm~ Delegation.pm --- 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($deleg +ated,$wantarray,$invocant,$to[0],$as,\@args); + die $@ if $@; } } elsif (@as==1) { @@ -60,6 +61,7 @@ foreach my $to (@to) { next if exists $delegated->{$t +o}; push @results, delegate($deleg +ated,$wantarray,$invocant,$to,$as[0],\@args); + die $@ if $@; } } else { @@ -69,6 +71,7 @@ my $as = shift @as; next if exists $delegated->{$t +o}; push @results, delegate($deleg +ated,$wantarray,$invocant,$to,$as,\@args); + die $@ if $@; } } }

Replies are listed 'Best First'.
Re: Re: Re: Class::Delegation is incompatible with exceptions?
by Jenda (Abbot) on Jun 13, 2003 at 16:58 UTC

    I think that the best thing to do would be to change the lines 96-97 from

    ? eval { [$target->$as(@$args)] } : eval { $target->$as(@$args) };
    to
    ? [$target->$as(@$args)] : $target->$as(@$args);
    I think the eval simply doesn't belong there. We know that the method does exist already thanks to the
    return unless eval { $target->can($as) };
    above and if the method feels like throwing an exception I don't think the Class::Delegate should interfere. I think we should ask TheDamian why is the eval{} there.

    Jenda
    Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
       -- Rick Osborne

    Edit by castaway: Closed small tag in signature