Make failing pleasant and never fear it again
There are two ways to react when we fail.
We are embarassed, humuliated even. It's a negative emotion and we don't like it. Because it's not pleasant we don't want to revisit the problem, to think about it. We put it away and we carry on. And we make the same mistake again (or a similar mistake). We feel embarassed. We don't like it. We don't want to think about it. And so it goes on.
Or we accept that failing is part of the process. We expect to fail and we detach the failure from any emotion: it's not pleasant or unpleasant, it's not personal, it's not a reflection of who we are. When we fail we look at what it's telling us: instead of shying away we dwell on the failure and we take it for all its got. And when we're done we have improved and we won't ever fail that way again.
How we feel about failing is the single most influencial factor for how much we can learn from ourselves.If we recognise that failures are valuable learning opportunities we can look forward to failing and each time we fail we improve a little more. What went wrong? Do we need to change the way we do things? Change how we approach the problem? Improve our knowledge? Surround ourselves with different people?
When you fail, focus on what you can do better so that it never happens again, rather than focusing on how terrible you are.