In reply to Alex Riley:
Relax. Get into a position that minimises the stress on your calves (and ideally your mind), get the balls of your feet on the holds, drop the heels, relax your legs and take some deep breaths to compose yourself. Once you've settled down take whatever action is required to improve your situation, be it resting longer, putting in gear, climbing down, or pressing on to a better position.
Tired legs seem more prone to it but that's sometimes unavoidable.
jk