This is a great question. I have always tried to use any failures or setbacks as opportunities to learn and for personal growth. Sometimes it is hard to remember that when one is going through it, but I feel that trying to keep a healthy perspective can do wonders.
Not getting the job I wanted, the promotion I wanted, or the amount of money I wanted are experiences I have had. I can say that my career overall has probably been better than I could have planned (over the last 14 plus years), and that every time a door closed, I was presented with another opportunity.
I think it is also a good idea to remember that some level of failure (either in professional or personal life) is part of the human condition. As long as an individual attempts to learn and/or grow from it, it really isn't a failure.
Thank you and have a great day,