My group is developing a service-based (.NET WCF) application and we’re trying to decide how to handle exceptions in our internal services. Should we throw exceptions? Return exceptions serialized as XML? Just return an error code?
Keep in mind that the user will never see these exceptions, it’s only for other parts of the application.
WCF uses
SoapFaultsas its native way of transmitting exceptions from either the service to the client, or the client to the service.You can declare a custom SOAP fault using the
FaultContractattribute in your contract interface:For example: