There is no such thing as failure.
There is only information.
If something doesn’t work out there is important information there.
Don’t put emotion into it.
Just detach from whatever the situation is.
Stop agonizing and create distance.
Do not berate yourself.
Don’t project or make it worse that what is.
If your mind is racing tell it to stop immediately.
Distance will allow you to see what the information is.
From there you can decide which way to go.