more safe checking whether error msg is set or not