The best way to deal with a failing erection is to ignore it.
Don't go all Little Engine That Could on our vaginas and think you're the little penis that can. While you're fumbling away, or worse yet, thrusting with Mister Softee thinking we might not notice, we are definitely noticing.
Instead of playing your minor infraction off by pretending it's not happening, admit that your penis is being temperamental. Crack a joke at that finicky bastard's expense. And then resolve the situation by focusing on us until you're ready for another round.
And yes, the same rule applies to premature ejaculation. It's not a big deal unless you act awkward and make it one.