WPF global exception handler [duplicate]

You can trap unhandled exceptions at different levels: AppDomain.CurrentDomain.UnhandledException From all threads in the AppDomain. Dispatcher.UnhandledException From a single specific UI dispatcher thread. Application.Current.DispatcherUnhandledException From the main UI dispatcher thread in your WPF application. TaskScheduler.UnobservedTaskException from within each AppDomain that uses a task scheduler for asynchronous operations. You should consider what level you need to … Read more

Can’t get ArrayIndexOutOfBoundsException from Future and SwingWorker if thread starts Executor

I’m not sure it adds much, but I got the expected Caused by using the variation of takteek’s answer shown below. I ran it from the command line to be sure the IDE wasn’t “helping”. $ java -cp build/classes TableWithExecutor StartShedule: PENDING -> STARTED java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2 at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222) at … Read more

Is there a difference between “throw” and “throw ex”?

Yes, there is a difference; throw ex resets the stack trace (so your errors would appear to originate from HandleException) throw doesn’t – the original offender would be preserved. static void Main(string[] args) { try { Method2(); } catch (Exception ex) { Console.Write(ex.StackTrace.ToString()); Console.ReadKey(); } } private static void Method2() { try { Method1(); } … Read more

Why is it bad style to `rescue Exception => e` in Ruby?

TL;DR: Use StandardError instead for general exception catching. When the original exception is re-raised (e.g. when rescuing to log the exception only), rescuing Exception is probably okay. Exception is the root of Ruby’s exception hierarchy, so when you rescue Exception you rescue from everything, including subclasses such as SyntaxError, LoadError, and Interrupt. Rescuing Interrupt prevents … Read more

How to write trycatch in R

Well then: welcome to the R world 😉 Here you go Setting up the code urls <- c( “http://stat.ethz.ch/R-manual/R-devel/library/base/html/connections.html”, “http://en.wikipedia.org/wiki/Xz”, “xxxxx” ) readUrl <- function(url) { out <- tryCatch( { # Just to highlight: if you want to use more than one # R expression in the “try” part then you’ll have to # use … Read more

VS2010 does not show unhandled exception message in a WinForms Application on a 64-bit version of Windows

This is a nasty problem induced by the wow64 emulation layer that allows 32-bit code to run on the 64-bit version of Windows 7. It swallows exceptions in the code that runs in response to a notification generated by the 64-bit window manager, like the Load event. Preventing the debugger from seeing it and stepping … Read more