How to catch unhandled exceptions in LINQPad.Controls onClick actions?
I've tried with this (Linqpad5):
void Main() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //throw new Exception("Ex1"); new LINQPad.Controls.Button("Fioo", (_) => { //insn't catched throw new Exception("Ex2"); }).Dump(); } void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { var ex = (Exception)e.Exception; "Exception catched2".Dump(); } private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = (Exception)e.ExceptionObject; "Exception catched1".Dump(); }
Comments
Try the latest beta - it has a static Control.UnhandledException event.
Any chance we can get this in Linqpad5 as well?
When will you update the LINQPad.Runtime nuget to include this?
It's now been updated.