When mistake happens it is best to put it aside immediately, store it in one imaginary box inside your head where it will be waiting the for the right moment.
In that way dealing with mistake will not influence the task at hand.
After that, choose the moment in which you can think about your mistake and remove it from the box.
Now your mistake is harmless and you can analyze it, think about better options and learn from this experience.
After you are done, put this mistake back in it’s box and store it in some safe place inside your brain. Keep it inside as a lesson but in some safe place it will not bother you anymore.
Learn from your mistakes and then move on…