Error Handling


Is it adviced to have Try/Catch block only at the entry level services and not in the services which we call from this entry level services. wM always bubbles up the exception at any level to the caller. hence would like to know which one would be the ideal one to have : having Try/Catch only at the main service that calls other services or in all services ?


Hi Bala,
It’s always better to have a TRY/CATCH block in the main service rather than having it in each and every sub-service.


Hello Bala,

Well, I would perhaps be less categoric than Pradeep.
Indeed, in almost all cases, you would like to have the error handling at the top level.
However, it could be usefull to have it also in the sub levels. As an example, you could have a loop in the a service (not the main one) calling a subservice. If the subservice fails, you might want and continue the loop and still process the next elements after you have reported the error.
To do that, you would need to have a try/catch block in the loop in the service.

So, to sum up, I would say my point of view is to have by default the try/catch block in every main service, but to keep the possibility of using it somewhere else for process reasons.

Best regards,