public delegate void FunctionThatThrowsException();
public static void Main()
Console.WriteLine("-----------------");
RunAndLogCatchedException(ThrowException);
Console.WriteLine("-----------------");
RunAndLogCatchedException(TryCatchThrowException);
public static void ThrowException() {
throw new Exception("Exception thrown at ThrowArgumentNullException (line 16)");
public static void TryCatchThrowException() {
throw new Exception("Exception thrown at TryCatchThrowArgumentNullException (line 22) but it says it was thrown at line 26");
public static void RunAndLogCatchedException(FunctionThatThrowsException func) {
Console.WriteLine(ex.ToString());