WCF Exception Handling

If an exception occurs in my WCF service, what is the best way to report this error to the client?

Should I register it in the service and reconstruct the exception of soap? Or should I go into it and return a user-friendly message?

+7
c # exception-handling web-services wcf
source share
3 answers

Using a strongly typed or non-typed FaultException is the way to do this. There is an excellent article Simplifying WCF: Using Exceptions as Failures , which describes how to use them. As stated in the article, depending on the complexity of your service, you can choose a simpler non-fixed exception FaultException and pass the exception information to the client.

+11
source share

I would register it and throw a FaultException . When you throw a FaultException, you can pass a user-friendly message back to the client.

+1
source share

The exception should be an exceptional event, so you should not worry about nice messages. If exceptions occur only when there is an error, simply roll it up as a general exception and write it down. There should be no problem.

However, when exceptions occur as part of your normal process, a good idea is a good idea.

0
source share

All Articles