There are two ways to relate to failure in a healthy way. One is to realize that all of our failures will LEAD to greater success as part of a process.
The other way is even better. To realize that the failure is ITSELF a success. Not that it will LEAD to something better but that the experience itself was part of your growth and a SUCCESS.
כי נפלתי קמתי כי אשב בחושך ה' אור לי - The falling is itself rising, the sitting in the dark is itself light.
[Rav Charlap ztz"l]