https://en.wikipedia.org/wiki/Learned_optimism
Learned optimism is the idea in positive psychology that a talent for joy, like any other, can be cultivated. In contrast with learned helplessness, optimism is learned by consciously challenging any negative self talk.
Learned optimism was defined by Martin Seligman and published in his 1990 book, Learned Optimism.[1] The benefits of an optimistic outlook are many: Optimists are higher achievers and have better overall health. Pessimism, on the other hand, is much more common; pessimists are more likely to give up in the face of adversity or to suffer from depression. Seligman invites pessimists to learn to be optimists by thinking about their reactions to adversity in a new way. The resulting optimismone that grew from pessimismis a learned optimism. The optimist's outlook on failure can thus be summarized as "What happened was an unlucky situation (not personal), and really just a setback (not permanent) for this one, of many, goals (not pervasive)".