I have read this question: What is the best approach to handle exceptions in WCF service?
Which answers how to handle exceptions.
I have seen few services that return a MyServiceResult
class containing both Data and an Error object (if any) for every method. and never throw FaultException
s. so the client will receive this information as a "graceful" response in the result.
e.g.
[OperationContract]
MyServiceResult Login(string userName, string password);
My question which is a better approach to handle errors and why?