I have a self hosted Net Tcp WCF service and I have the following method
Subscribtion GetSubscribtion(int subscribtionId)
{
Subscribtion s;
if (_subscribtionTable.TryGetValue(subscribtionId, out s) == false)
{
Console.WriteLine("Not Found SessionID");//for debugging
throw new ArgumentException("Invalid Subscription Id");
}
return s;
}
Is throwing exception is a good practice for reporting erros in service programming?
In WCF you should instead be defining and throwing a FaultException. The following articles provide examples and details: