Every cloud has a silver lining. When one door closes, another opens. Blessing in disguise. Make lemonade.
American English carries an unusually large stock of phrases whose function is to locate the gain inside a loss.
They are offered to other people, out loud, shortly after the bad news — which makes them a persuasive move rather than a private consolation.