Hello !

While we are working on Groovy migration at Nereide, we figured out that
using ‘run service’ DSL method instead of returning the errorMap, a
‘ExecutionServiceException’ is thrown :

if (ServiceUtil.isError(result)) {
    throw new
        ExecutionServiceException(ServiceUtil.getErrorMessage(result))
}

Can anyone explain the intention behind that implementation ?

I suppose that we need to catch any service call like :

try {
    serviceResult = run service: 'createQuoteAdjustment', with:
        [*: quoteAdjustement, quoteId: quoteIdTo]
} catch (ExecutionServiceException e) {
    return ServiceUtil.returnError(e.getMessage())
}

instead of : 

serviceResult = run service: 'createQuoteAdjustment', with:
[*: quoteAdjustement, quoteId: quoteIdTo]

if (ServiceUtil.isError(serviceResult)) {
    return serviceResult
}

I wonder if exception management is more costly than simple return.
May the GroovyEngine should handle the exception ? I do not grasp yet
the benenit of this implementation.

What is the good way to handle service errors within services in Groovy?

Thanks

Gil

Reply via email to