This is not an uncommon scenario, especially during the first semester, and it can be hard for you to maintain your composure and to say something helpful. Please remember that your son is probably overly anxious and will likely do better than he fears. In fact it's not uncommon for parents to lose sleep after such a phone call, only to discover the next day that their son did fine and scarcely remembers having been anxious at all. In times of crisis, your student can unload troubles or tears and, after the catharsis, return to a routine, relieved and lightened, while you inherit the burden or worry.
Students can be resourceful in solving problems.
We will add only a few words to this excellent advice. Be sympathetic, but more importantly, support your child by expressing confidence in his or her ability to solve the problem. Note, please, that you are not coming up with the solution. But most importantly, read the advice above again. So, hang up and go back to sleep.