I'm having trouble myself figuring the balance between thinking on what could've been done better and relying on time to heal the wounds
I'm guessing you kept this purposefully vague because you don't want to share the details, but hopefully you can find someone to confide in - in my experience bottling it up made me even more depressed
A positive way of looking at failures is that if you know there's something that can be worked on, that means it's worth it to try again. Don't give up as long as it's still possible to improve yourself