I'm using the CXF for developing webservices.
But I was wondering what is Best Practice for handling exceptions? Let's say I have a webservice-operation, create(User user). The incoming user is an instance of my User domain class, and can be saved directly by the UI Team by calling user.save()
If the save() for some reason fail (e.g. some Network connectivity fail , or some data validation error from User DTO ), how would Best Practice dictate that I serve this exception to the client?
I mean: Which type of Exception would be suitable?
Should this Exception be included in the operations signature ??
public Response createUser(User user);
@WebService
public interface EmpService {
public Response createUser(User user);
}
And how should the client-side handle this exception?
response? or threw a separate exception like thispublic Response createUser(User user) throws MyOwnUserException;