Failure is a teacher. When you make a mistake, two things will happen:
You learn from it, or
You walk away from it not learning anything.
Failure cannot be your teacher if you are not ready to learn from it. Failure will proudly be happy to be your teacher only if you are ready to learn from it. You cannot learn from it if you close your mind. To learn from it, open your mind to learn something new. If you learn from failure, you are not a failure. You are just a learner.