I have a simple WCF service that carries out a simple operation:
[OperationContract]
DoSomething (Stuff input);
If an exception occurs inside DoSomething
then a FaultException
will be returned. Given that all the client needs to know is whether something went wrong, would you say that there's no need to define a FaultException
in this scenario?
It is always good practice to return a FaultException
, since if you do not, the channel will be faulted and cannot be used again.
The decision what information need to be sent to the client is taken in the configuration (in service behaviour):
<serviceBehaviors>
<behavior name="myName">
<serviceDebug includeExceptionDetailInFaults="true" />
// ....
In fact I always implement IErrorHandler
behaviour on the service to catch all exceptions and return FaultException<T>
so that I do not have to do it in all my operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With