It goes with the territory. Anything that takes skill, endurance, and that is worthwhile will extract the price of periodic 'failure.' Those who can't deal with it, soon quit and do something less challenging, until maybe they are doing nothing at all. Just stick with it, keep gigging, and keep trying to improve. Every time I screw something up, I at least promise myself not to make that mistake again, and it inspires me to practice whatever it was I messed up until I can't play it wrong. Eventually you get your share of good nights, fun gigs, great audience, etc. But there will always be the off nights, whether it's your own playing errors or a poor audience, or crappy venue, whatever. Just keep going and live for the good ones.
One thing that is a sort of two-edged sword is that every performance is a brand new opportunity. It's a new opportunity to play great or to play poorly. Doesn't matter how great or poor you were the last time out. Each new gig is a fresh situation. I think it helps to see it this way, not least of all because that's the reality. Just carry on and keep working to get better.
And yeah saxpunter, you took the words out of my mouth. I couldn't agree more with what you said: "Dont ever apologise, sometimes you are ahead, sometimes you are behind. In the end the race is only with yourself."
I guess looking at the title of this thread, I would say that for a real musician who wants to get better, failure is as much a motivating factor as success. In other words, the road to success is paved with ****-ups.