WCF - Error handling in service layer
Posted on 2014-11-05
I am working on a WCF service and working on a exception handling.
I'd like to know the best practice for returning exception.
Option 1 : use request/response pattern
public ServiceResponse MethodTest(ServiceRequest)
1. If there is any exception than faultexception object will contain the error and remaining 2 object will be null
2. If there is Business rule failure than ValidationError will have all the error and remaining 2 objects will be null
3. If it is sucess responseobject will contain the data
Option 2 : returning faultexception
public ResponseObject MethodTest(string)
1. If there is any exception than throw faultexception with error
2. If there is Business rule failure than throw faultexception with validationerror
3. If it is sucess return responseobject will contain the data
I am not able to decide between this 2 options, which option should I use , please suggest.