This has never happened to me in an actual exam for long enough, but I have been on the verge of panic attacks in exams when it becomes apparent that I'm really not sure whether I'm right. I had it recently in a Financial Reporting exam for a qualification - if I fail the exam once and then fail the retake of the exam again just one more time, I get fired, so big pressure. I almost got to a point where I thought I had to put my hand up and ask to redo the exam when I had calmed down, but I managed to calm myself by concentrating on the parts I could do, and going back to the more difficult parts, where I made a reasonable attempt, even though I wasn't 100% sure of what I was doing. I find that once you get started on a question and get involved in it, things do start to calm down - and if it's a harder question, use the difficulty to distract you into thinking about it, rather than making you panic, if that makes sense.
As for making mistakes, preparation beforehand will reduce the fear significantly - after each mock exam or practice question I've done during Maths A Levels, in University and in my job now, I make a list of all the points where I make mistakes and find memorable ways to ensure I don't do them again, whether it's by making it into a silly joke or whatever, whatever works for you.