it's very individual and you may not find a "recovery template". Personally, I find that best remedies are 1) attaching yourself to a bigger goal, where even "at least I tried" and "at least I've advanced X area by a few steps" are fulfilling narratives. 2) finding something no matter how small, where you excel. Hobbies are great. Maybe your startup is a mess, but your bird dog yoga pose is pure perfection.
(1) helps deal with the shocks of failures and (2) helps refill your confidence tank to try at the problem one more time.