I am using WCF and need to catch all the exceptions that can occur when calling a method on the service proxy, so that I can then instead return a status value. I want to do this to encapsulate/hide the underlying WCF implemenation. An example code would be this:
public Status StartProcess(string outputFolder)
{
return service.StartProcess(outputFolder);
}
service.StartProcess
returns a Status
-enum and I would like to catch all possible WCF exceptions that can occur from the call to service.StartProcess(outputFolder);
so that I can return a corresponding Status
-enum. From testing I arrived at this:
public Status StartProcess(string outputFolder)
{
try
{
return service.StartProcess(outputFolder);
}
catch (System.ObjectDisposedException) // occurs, when client closed the connection previously
{
return Status.ClientDisconnected;
}
catch (System.ServiceModel.CommunicationObjectFaultedException) // occurs, when server unexpectedly closed the connection previously
{
return Status.CommunicationFailed;
}
}
So my question is: Are these all the exception I have to handle in this case or are there other exceptions I should anticipate?