Improve console/launcher error handling. (reverse-merged from commit 9ed8bafe723075a75931c565f1338f1abc806d28)

It added a regression that blocked Swing events (or something...). Will investigate later.