Why does $errors become empty