set and unset error as needed