Error dialog being displayed in a headless context

This was causing an infinite cycle of java.awt.HeadlessException in case handleError was called in an environment without display.

In applications with a headless context, the error dialog will now be skipped.