using System;
public class Program
{
public static void Main()
try
DoSomethingThatMightFail();
}
catch (Exception ex)
Log(ex, "An error occurred");
throw;
public static void DoSomethingThatMightFail()
// This will always throw a DivideByZero exception
var x = 42;
var y = 0;
int z = x / y;
static bool Log(Exception ex, string message, params object[] args)
Console.WriteLine(message, args);
return false;