Maxwell Maltz said this quote

Our errors, mistakes, failures, and sometimes even our humiliations, were necessary steps in the learning process. However, they were meant to be means to an end - and not an end in themselves. When they have served their purpose, they should be forgotten. If we consciously dwell on the error, or consciously feel guilty about the error and keep berating ourselves because of it, then - unwittingly - the error or failure itself becomes the goal that is consciously held in imagination and memory.