Hi Clowns
There's already some great comments on this and hopefully here's a couple more:
=> Yes, ideally this shouldn't happen. So the key is preparation, preparation, preparation.
=> Yes you should both practice and rehearse over and over until you're done!
=> And then you should ask of every routine and every part of each routine and all the parts in between the routines ... "What if ....?" and see just what COULD go wrong.
=> Then decide what you'll do!
=> The worst thing is to hesitate. To be caught cold. It shows! Do NOT be phazed. Yes some useful 'lines' help. Great ones already, here's a few I use:
--> "Whoops ... first time
that's happened again!"
--> "Oooooh ... sudden gust of gravity"
--> "Looked easier in the book"
--> "Great audience ... wish I had a better act"
--> "No, it WAS the right ending ... wrong trick!"
--> When kid gives 'wrong' answer: "So you're not Cindy then!"
=> Obviously what you do is hugely determined by what went wrong. Clumsy drops and similar can usually be passed over with a line. But when the trick cannot be recovered, that's a whole different matter. As above, avoidance is the best tactic but you can be prepared for certain things by having 'spares'. By this I mean another prop item, or second gizmo or gadget or simply another way of doing it.
=> The bottom line is that it generally doesn't matter. It's only a trick! You and your audience are what it's about ....
=> And be sure to learn from the experience so that it doesn't EVER happen again.
=> Unless you WANT it to!
Yes ... some great comedy moments have been created because they started with an accident or surprise event ... but the worth was spotted and then routined in forever.
=> A classic example of this is in an earlyish David Copperfield show. He's doing an introduction and spots a girl in the audience with some binoculars. He halts the patter intro almost mid sentence and goes down and gets them. He shows the entire crowd of perhaps a thousand what she's using .... and she's in the front row!!!!!!
Then he trains them on her ... "See how you like it"

) Then he scans the rest of the audience, especially connecting with those way up in the gods.
A great bit of business that happened for real one night. She wasn't initially in the very front row, but they took it and turned it into a warm, comedyy bit and now plant a girl there each night!
All for now ...
John Gordon
=> The Infotainer <=