In some cases people even let these feelings balloon into a generalization. You may think to yourself, "I'm an idiot for not knowing that," or "I never make the right choice, I must be stupid."
Ironically this attitude does make you less intelligent. It's self-fulfilling prophecy, if the belief that you are going to fail stops you from even trying then you automatically fail. Then you attribute the new failure to your inability to produce results and the process continues to drive you deeper into a downward spiral.
This is all a result of the hindsight bias (the inclination to see events that have occurred as more predictable than they in fact were before they took place.)
The key here is to not blame yourself. You were not born all-knowing. Failure is a process by which we learn. Just chalk the blunder up to learning and resign yourself to be better in the future.
The following is an excerpt from Blair Singer's book "Little Voice" Mastery. This is technique # 14 (of 21) that will help you in your fight against the hindsight bias.
How to Banish "Should've, Would've, Could've" Thinking and Regain Power
"When you're feeling that you've failed to accomplish something, and your little voice starts beating up on you, it's time to make another list. This time, your list will include all the things your little voice says you should have done, could have done, or would have done.
For example, your list might read, "I could have gone to the gym," "I should have called my mother," or "I would have made more sales had I made more calls." List everything you can think of. Just be as whiny as you can possibly be.
Then read them carefully, over and over again, considering each one. If you have to, add to the list until you get them all out. Interestingly enough, at some point you'll find them humorous, you'll laugh, your energy will lift, and your guilt will erode as you're able to let each of them go. This magical little tool sort of cleans up and corrects that little voice in your brain.
The cool thing about this technique - and actually, the rest of them too - is that if you repeat the techniques, they become automatic. You may not even need to write them down, because if you've practiced them enough, your brain stops making those justifications.
As for that pesky guilt, you can try this, although I'll warn you, it's a tough one. When you get to feeling guilty about a failed accomplishment, assume a push-up position on the floor and hold it for as long as you insist on feeling guilty. Stay there until you let go of that guilt, even if your arms are quivering and the sweat is rolling down your forehead. It's not so easy, is it?
Maybe next time you'll ease up on yourself."
For more on this subject and the remaining 20 techniques to winning the war between your ears please refer to Singer's book, "Little Voice" Mastery.