Don't just clear the has-error class, abstract out the error detection function to use it when switching.