Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF Exception Handling

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

Should I log it on the service and rethrow a soap exception? Or should I log it and return a user friendly message?

like image 697
mcass20 Avatar asked Oct 20 '10 14:10

mcass20


1 Answers

Using strongly typed or non-typed FaultException is a way to accomplish this. There is an excellent article Simplifying WCF: Using Exceptions as Faults that describes how to use each. As the article points out, depending on complexity of your service you may opt to choose simpler untyped FaultException and pass exception info to the client.

like image 161
zam6ak Avatar answered Sep 20 '22 16:09

zam6ak