CSharp examples for Custom Type:Exception
Exception Logging Filter
using System;//ww w . java 2s .co m using System.ComponentModel; class LoggingFilter { static void Main() { try { UnreliableMethod(); } catch (Exception e) when (Log(e)) { } } static void UnreliableMethod() { throw new Exception("Bang!"); } static bool Log(Exception e) { Console.WriteLine($"{DateTime.UtcNow}: {e.GetType()} {e.Message}"); return false; } }