If a first attempt falls short, the result can still reveal a gap in understanding or practice. A learning goal asks what the attempt taught you and what kind of feedback would help. That does not mean every failure is valuable on its own; repetition without a change in method may simply reproduce the same result.
The idea often called a growth mindset is that ability can develop with effective strategies, support and practice. It should invite better conditions for learning rather than place every difficulty on the learner’s attitude.