We are trying to figure out a way to modify WCF service behavior to catch all exceptions and instead of returning faults to the client, it will populate a custom return object with exception data and return that. So far, we haven’t had much luck. I found this example: Catching custom faults
However, it doesn’t return custom types as we would like it to. What other options are there?
Thanks!
If you want to have an interoperable and “by-the-standard” service, you should always return
FaultException<T>SOAP faults from your service to the client.Since that type takes a generic
<T>, you can basically put anything into that type there to report back your errors. That type needs to be decorated with a [DataContract], and its members that need to be passed back with [DataMember] attributes.When you catch those execptions on the service side and return a
FaultException<MyErrorInfo>(or whatever you’ll end up calling your error class), you also need to decorate your operations with aso that your clients will be able to catch the
FaultException<MyErrorInfo>and handle it.