fix undefined var when exception is raised