trap error messages correctly in the parser