using System.Runtime.ExceptionServices;
public static void Main()
ClientCaller clientCaller = new ClientCaller();
clientCaller.AutoRateUsingThrow();
clientCaller.AutoRateUsingExceptionDispather();
public void AutoRateUsingThrow()
ex.Data.Add("IAutoRatingInfo", "haha");
public void AutoRateUsingExceptionDispather()
ex.Data.Add("IAutoRatingInfo", "haha");
ExceptionDispatchInfo.Capture(ex).Throw();
throw new Exception("I am a bad developer.");
var freightAutoRater = new FreightAutoRater();
freightAutoRater.AutoRate();
Console.WriteLine("Current code without modification");
Console.WriteLine(ex.StackTrace);
public void AutoRateUsingThrow()
var freightAutoRater = new FreightAutoRater();
freightAutoRater.AutoRateUsingThrow();
Console.WriteLine("AutoRateUsingThrow");
Console.WriteLine(ex.StackTrace);
public void AutoRateUsingExceptionDispather()
var freightAutoRater = new FreightAutoRater();
freightAutoRater.AutoRateUsingExceptionDispather();
Console.WriteLine("AutoRateUsingExceptionDispather");
Console.WriteLine(ex.StackTrace);