It's only human to want our artwork to turn out right, the way we'd envisaged and preferably even better. It's only human to be disappointed when things turn out wrong, whether only a little different to what we'd thought it would or should be, or whether drastically different. What is crucial in our artistic development is how we deal with what we (and others) perceive as failure, whether we let it damage our creativity, even paralyze us into inaction, or whether we allow ourselves to learn from it, find the motivation to try again. In the words of Samuel Becket, we need to learn to "Fail better".1
When a painting is a disaster, don't throw a tantrum, rip it up and toss it in the bin. Put it to one side for a more subjective look when you're feeling less frustrated. (Note I said less frustrated, rather than not frustrated at all.) You need to identify the problem in order to fix it.
Was it the idea, or was it technique that let you down? Was it the wrong medium, or perhaps scale? Is there anything working in it at all? Although it may feel like it, it's extremely unlikely that nothing whatsoever is working, all the way back to the first mark you made on the sheet of paper or canvas.
What would you fix? The composition, colors, mark making? Aim to be specific about what's irking you. A general "it's all rubbish" isn't going to help, you need to pinpoint where, when, and what went wrong as far as you can. Sometimes it's not very far (for instance letting the colors get murky as you mixed) and other times you can identify quite specific things (for instance not working out part of the perspective methodically enough before you started paintings).
Decide if it's a painting that might be rescued or reworked, whether it could serve as an interesting lower level for another painting over the top, or as part of a mixed media artwork or collage. Don't disregard its potential as a learning exercise, drawing over it to investigate how it could without aiming for it to be a finished piece.
It's not necessarily true that you can achieve anything you want in your art, but it is true that you can try to do anything you want. If you don't try, you're guaranteeing failure. If you stick to what you know you can do, you're in a rut. If you do try, you may fail. That's not the same as being a failure. Fear of failure hampers creativity and artistic development. Allowing yourself to learn from things that go wrong, that's failing better.
1. Writer Samuel Beckett, in Worstward Ho (1983): Ever tried. Ever failed. No matter. Try again. Fail again. Fail better.