issue #1149 changed order of things around to log exception before doing anything else