From the Harvard Business Review:
Disappointments are inevitable and unpleasant — a missed promotion, a failed project, a poor investment — but you can always learn something from them. To constructively deal with your next setback, think through what happened. Distinguish situations that were predictable and preventable from those that were unavoidable and beyond your control. Ruminating over something that didn’t go your way — and that you couldn’t control — will only frustrate you further. For situations that you could have handled differently, consider them in positive terms: What can you do differently next time? What lessons can you learn from the mistakes you made? And remind yourself of what’s going well in your life, so you don’t let the disappointment take an outsize role in your brain. It might sound like a cliché, but keep the setback in perspective — and try to let it go. You may be tempted to play the situation over and over in your head, but staying preoccupied with it will only create unnecessary stress.
Adapted from "Dealing with Disappointment," by Manfred F. R. Kets de Vries