throw exception when ERROR event occurs

To prevent cname swapping when an ERROR is encountered in the setting up the new environment.