2

I'm using .net svc services with .Net framework 4.5 and for production purpose I have to set includeExceptionDetailInFaults to false in my web.config file.

However sometimes I need to have custom errors returned by my services.

I tried to use the System.ServiceModel.Dispatcher.IErrorHandler.ProvideFault method to create a custom FaultException with no result, returned error message is always the generic message.

Is it possible to do it ? If yes how ??

Thanks

Balayesu Chilakalapudi
  • 1,386
  • 3
  • 19
  • 43
bizibiz17
  • 31
  • 5

1 Answers1

0

Yes, it is possible to return custom error messages. Just wrap your message inside of a FaultException:

try
{
   // some calls go here
}
catch (Exception ex)
{
   throw new FaultException(ex.Message);
}

Clients calling your service, see a clear message instead of the exception details, when an errors occurs.

domenu
  • 455
  • 8
  • 12