Exceptions are a great source of stress and suffering. Each exception thrown by our application must be caught handled before the user sees it. Failing to do disturbs the balance of our application. We can use a generic exception handler, but we never can be truly certain we’ve found the true exception. So often the Truth is hidden within an inner exception. It may also be hidden within that exception’s inner exception .
To find truth, how deep must we go?
private void Application_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { try { MessageBox.Show(e.Exception.Message); MessageBox.Show(e.Exception.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.Message); MessageBox.Show(e.Exception.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.InnerException.Message); } catch { } }
If we go deep enough, perhaps we will not find an InnerException
but inner peace, instead.