Error-handling code for parser