For ENG-5962, tweak error handling to log unexpected errors properly