Bad (undesired) things happen all the time. At least we think they are bad, because we are putting them in the context of some other outcome that we want.
But, as this Chinese proverb about luck points out, everything ends the same way (we die). Whether or not a specific event or circumstance is good or bad totally depends on your frame of reference.
So why not assume something that doesn’t go your way, and is not in your control to change at this point, is part of a larger outcome that is actually preferred?
There are almost certainly experiences or circumstances in your life that upset you at the time and now you can look back and say, “oh wow I’m glad things went that way.”
Instead of being reactive in that mindset, be proactive.
Instead of thinking that something happened to you, think of that experience happening for you. Resolve to turn that outcome into something positive and think proactively about what may be able to fall into place now that the path has changed.