WCF Exception Handling

前端 未结 3 1953
粉色の甜心
粉色の甜心 2020-12-17 00:49

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?

3条回答
  •  Happy的楠姐
    2020-12-17 00:54

    An exception is supposed to be an exceptional event, so you shouldn't worry about nice messages. If exceptions only occur when you have a bug, just rethrow it as a generic exception and log it. Should not be a problem.

    However, when the exceptions occur as part of your normal process, returning nice messages would be a good idea.

提交回复
热议问题