Disclaimer: I am a consultant at Amazon Web Services, and this is my personal blog. The opinions expressed here are solely mine and do not reflect the views of Amazon Web Services (AWS). Any statements made should not be considered official endorsements or statements by AWS.
You can determine type of exception in c# in two ways.
catch (Exception ex)
{
if (ex is System.ServiceModel.FaultException)
{
// do something
}
else if (ex is System.Web.HttpException)
{
// do something
}
}
This is useful when you don't have assembly reference of exception type. In that case, you can use string comparison.
catch (Exception ex)
{
if (ex.GetType().FullName == "System.ServiceModel.FaultException")
{
// do something
}
else if (ex.GetType().FullName == "System.Web.HttpException")
{
// do something
}
}