It starts with an inward locus of control, https://en.wikipedia.org/wiki/Locus_of_control
Individuals with a strong internal locus of control believe events in their life are primarily a result of their own actions: for example, when receiving exam results, people with an internal locus of control tend to praise or blame themselves and their abilities. People with a strong external locus of control tend to praise or blame external factors such as the teacher or the difficulty of the exam.[2]
Focus on learning on how to take that setback and analyze your roll in the setback. Now you can turn the setback into a learning opportunity. Adjust your approach to optimize the odds of success in your favour for the next iteration.
It is also critical to realize there are two types of games in life.
1) Finite Games: Known players, fixed rules, an agreed-upon objective (e.g. baseball). In a finite game, there is a clearly defined end point and there are winners and losers.
2) Infinite Games: Known and unknown players, changeable rules and the objective to keep the game in play (e.g. the cold war). There game ends when someone stops playing
Life and success are Infinite games. Failure or set backs only become permanent if you stop playing. If you keep trying and learning from your mistakes, setbacks become a temporary state.