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

I would say he's to fix the module and send a patch to the author ;-) In this case it seems all you have to do is to change the exception handling code in Class::Delegation so that it only changes some exceptions and rethrows the others without change. (Note I have no idea what is C::D supposed to do.)

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

  • Comment on Re: Class::Delegation is incompatible with exceptions?

Replies are listed 'Best First'.
Re: Re: Class::Delegation is incompatible with exceptions?
by diotalevi (Canon) on Jun 13, 2003 at 15:30 UTC

    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 $@; } } }

      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