Mistakes are inevitable. Learning to play through mistakes is its own skill, one that has to be learned. The technique for learning to play through mistakes is different than the technique for learning to play a piece.
I've learned two ways to practice a piece: Practicing for perfection, and practicing to perform. They compliment each other, but are done differently.
When practicing for perfection, it's important to not repeat mistakes, lest they become muscle memory. As you probably know, if you make a mistake when learning a piece, it's important to stop, slow down, and play the difficult part correctly several times before continuing. That's because once you've played a section wrong a few times, it's going to be muscle memory that will take a lot of work to correct. But if, after making a mistake, you stop, slow down, and correct the mistake a few times before continuing, you'll have a much easier time of learning it correctly.
Unfortunately, this way of practicing can have a side effect: It trains us to stop whenever we make a mistake. But you must not stop during a performance. So the way we practice to learn a piece correctly can give us a bad habit that hurts us when we play.
That's why there's a second mode of practice: Practicing to perform. After I've learned a piece using the above, careful technique, then I will practice it for performance. During practicing for performance, there is no stopping, for any reason. If I forget a part of it, I pick it up where I remember. If I play a wrong note, or chord, I keep going as best I can, however I can.
While practicing to perform, I remember where I goofed up, or what I forgot, or what felt difficult. Because after practicing to perform, I go back to practicing for perfection and carefully work on the parts I had trouble with. After which, I go back to practicing to perform again. It's an iterative process.
The key part is that every time I start to play the piece, I deliberately put myself into one of these two practice modes. If I am practicing for perfection, then I will stop and correct mistakes. If I am practicing for performance, then I stop for nothing.
During the next practice section, I will practice the piece for performance, cold. That's to check what it will be like when I perform it for others. This will probably show me weaknesses which will lead to some practicing for perfection, which is followed by practicing for performance.