In the immortal words of Henry David Thoreau "If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them. " Look at every adversity as a learning experience that's going to spring board you forward tomorrow to a new height!
Success is in the eye of the beholder and for as long as you fight and keep striving to do better each day you wake up you're not a failure. Discouragement, is married to doubt who is kin to despair who's also married to defeat. Have no fellowship with any of them. Keep your eyes on the prize and keep pushing forward and you'll be just fine.