I have the following method called asynchronously. I want to know how can I convert the System Exception
(that I might encounter during SQL operations) into a FaultException
.
Here is the method:
public List<Product> GetProductDetails(int productKey)
{
try
{
using (SqlConnection con = new SqlConnection(_connectionString))
{
SqlCommand cmd = new SqlCommand("usp_Get_ProductDetails", con);
........
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
......
}
}
}
}
catch(Exception ex)
{
//How can I convert this Exception ex into FaultException and then throw to client?
//throw new FaultException(new FaultReason(new FaultReasonText()), new FaultCode());
}
}