Failure, as applied to human effort, is rather rare in my experience. Much much more common is simple giving up. A decision taken that it is 'not worth' continuing. People persuade themselves and others to give up. Later they may call it failure, but the only failure involved was the failure to keep going. And that point, when giving up is most attractive, is almost always just before a real breakthrough, an opening that reveals a downhill ride to completion and success.
Hang out with people who forestall and minimise the attractions of giving up, who, when you leave their company, leave behind a verifiable trace of optimism, light, and interest in renewed effort.