I assume you are not asking about small mistakes of no consequence, but rather big important stuff.
When it happened to me, I kept saying that it can't be in vain. I made a del with myself, that I need to come out the other end better than I was before. I used those negative emotions to change myself and my life in a positive way.
For example, I quit smoking, started doing sports and improved my career all bases on some pretty bad stuff that I did.