Fix 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.
Merge pull request #155 from blay09/bug/handleerrorheadless

Prevent error dialog from being displayed in a headless context