If you suffer from being too hard on yourself, chances are that your mistakes tend to become a burden. That would be rather unfortunate, since you're probably bound to make mistakes all throughout your life. A mistake can make you discouraged with what you're doing by making you (falsely) think that you must be fundamentally bad at it. It can put you in an over-thinking state of trying to figure out the structure of the mistake so that you will never do this class of mistake ever again (or, even better a delusion, never do any mistake ever again). And since a mistake usually breaks something (or, at least, puts the Universe in less satisfying state in some way), it can make you ruminate over this "loss of value", especially if you have no way of fixing it (precisely the case when it is most irrational to ruminate over it).
I've discovered that, whenever my mind was starting to spiral into the aforementioned state, which is obviously toxic, saying to myself "It's okay, I'm learning" was enough to relieve me of all the weight. What this sentence means to me is the futility there is in trying to "figure out" the mistake. When children fall from their bicycle, they don't engage in an analysis of why they fell, they just hop on again and go on. Truth is, life is not engineering, and all that matters is experience, which you cannot trade with analysis, simply because it is way too complicated. The determined fool is going to go further than the paralyzed thinker.
With practice, I realized an additional power of "It's okay, I'm learning": it brings to the mind the only relevant piece of mistake analysis, which is assessing how legitimate the mistake was, relative to your place in the learning curve. There actually are mistakes we just repeat over and over again, that, I guess, we decided to just sweep under the rug at some point in our life. When such an "abnormal" mistake happens and generates a frustration, it is blatant that the trick "It's okay, I'm learning" doesn't work, as you know that would be lying to yourself, since you're definitely not in the process of learning this context anymore. In such cases, it gives you a signal that you need to take a step back and actually think things through and figure out how to fix it.
This creates a distinction between the no-action-required mistakes coming from actively learning, and the action-required mistakes coming from repeatedly ignoring an issue. The clarity of mind which comes from this distinction is incredibly valuable.