put exception handling code into handleException in exceptions.h