Things happen for a reason
While it's hard to receive bad news, I try to remind myself that things happen for a reason and that they can often be blessings in disguise.
In personal relationships, break-ups sting in the moment, but are often for the best in the long-run. While couples can work through differences, this can only happen if both people are committed to finding resolution. The break-up is evidence that there isn't a mutual commitment to do that. If left unchecked, the issues leading to the break-up will become worse, making both people miserable.
Getting a rejection from a "dream job" is similarly hard to swallow. But, if they aren't interested in having you as part of their company, it's likely they won't fully appreciate you and your capabilities, which will make you unhappy working there. It's their loss - make them feel it.