You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by Jean-Sebastien Delfino <js...@apache.org> on 2008/06/04 07:02:05 UTC

Changing throw IncompatibleInterfaceContractException to a log

I'm changing the throw new IncompatibleInterfaceContractException() 
statements in the composite builders to log statements. I need to do 
that for three reasons:

- Throwing that exception abruptly stops further processing, preventing 
us to continue validating the composite and log other relevant errors.

- That exception stops the composite builder and prevents me to build a 
domain composite when there's an incompatible interface in part of the 
domain.

- We're handling most other similar errors as logs so I'm not sure why 
we've kept that one as a thrown exception, for example in the following 
code:

                    	boolean isCompatible = 
interfaceContractMapper.isCompatible(compositeServiceInterfaceContract,promotedServiceInterfaceContract);
                     	if(!isCompatible){
                     		throw new 
IncompatibleInterfaceContractException("Interface of composite service 
"+promotedServiceName +" must be subset of the interface declared by 
promoted component service.", compositeServiceInterfaceContract, 
promotedServiceInterfaceContract);
                     	}
                     }

                 } else {
                     warning("PromotedServiceNotFound", composite, 
composite.getName().toString(), promotedServiceName);

if a "PromotedServiceNotFound" error is considered benign enough to just 
be logged, then an "IncompatibleInterface" situation (in that case the 
promoted service was found, so we're in a better shape here) is a good 
candidate for logging as well :)
-- 
Jean-Sebastien

Re: Changing throw IncompatibleInterfaceContractException to a log

Posted by Jean-Sebastien Delfino <js...@apache.org>.
Mike Edwards wrote:
> Jean-Sebastien,
> 
> What happens to the model object that is being constructed when this 
> error occurs?
> 
> I'm assuming this is a reference or a wire of some kind?
> 
> 
> Yours,  Mike.
> 
> Jean-Sebastien Delfino wrote:
>> I'm changing the throw new IncompatibleInterfaceContractException() 
>> statements in the composite builders to log statements. I need to do 
>> that for three reasons:
>>
>> - Throwing that exception abruptly stops further processing, 
>> preventing us to continue validating the composite and log other 
>> relevant errors.
>>
>> - That exception stops the composite builder and prevents me to build 
>> a domain composite when there's an incompatible interface in part of 
>> the domain.
>>
>> - We're handling most other similar errors as logs so I'm not sure why 
>> we've kept that one as a thrown exception, for example in the 
>> following code:
>>
>>                        boolean isCompatible = 
>> interfaceContractMapper.isCompatible(compositeServiceInterfaceContract,promotedServiceInterfaceContract); 
>>
>>                         if(!isCompatible){
>>                             throw new 
>> IncompatibleInterfaceContractException("Interface of composite service 
>> "+promotedServiceName +" must be subset of the interface declared by 
>> promoted component service.", compositeServiceInterfaceContract, 
>> promotedServiceInterfaceContract);
>>                         }
>>                     }
>>
>>                 } else {
>>                     warning("PromotedServiceNotFound", composite, 
>> composite.getName().toString(), promotedServiceName);
>>
>> if a "PromotedServiceNotFound" error is considered benign enough to 
>> just be logged, then an "IncompatibleInterface" situation (in that 
>> case the promoted service was found, so we're in a better shape here) 
>> is a good candidate for logging as well :)
> 

No change to the model object.

Looking further in this code (BaseWireBuilderImpl), there are 6 cases of 
incompatible interfaces, 4 were logged, 2 were throwing exceptions. I 
changed the 2 exceptions to log like the 4 other cases.

-- 
Jean-Sebastien

Re: Changing throw IncompatibleInterfaceContractException to a log

Posted by Mike Edwards <mi...@gmail.com>.
Jean-Sebastien,

What happens to the model object that is being constructed when this error occurs?

I'm assuming this is a reference or a wire of some kind?


Yours,  Mike.

Jean-Sebastien Delfino wrote:
> I'm changing the throw new IncompatibleInterfaceContractException() 
> statements in the composite builders to log statements. I need to do 
> that for three reasons:
> 
> - Throwing that exception abruptly stops further processing, preventing 
> us to continue validating the composite and log other relevant errors.
> 
> - That exception stops the composite builder and prevents me to build a 
> domain composite when there's an incompatible interface in part of the 
> domain.
> 
> - We're handling most other similar errors as logs so I'm not sure why 
> we've kept that one as a thrown exception, for example in the following 
> code:
> 
>                        boolean isCompatible = 
> interfaceContractMapper.isCompatible(compositeServiceInterfaceContract,promotedServiceInterfaceContract); 
> 
>                         if(!isCompatible){
>                             throw new 
> IncompatibleInterfaceContractException("Interface of composite service 
> "+promotedServiceName +" must be subset of the interface declared by 
> promoted component service.", compositeServiceInterfaceContract, 
> promotedServiceInterfaceContract);
>                         }
>                     }
> 
>                 } else {
>                     warning("PromotedServiceNotFound", composite, 
> composite.getName().toString(), promotedServiceName);
> 
> if a "PromotedServiceNotFound" error is considered benign enough to just 
> be logged, then an "IncompatibleInterface" situation (in that case the 
> promoted service was found, so we're in a better shape here) is a good 
> candidate for logging as well :)