Add option to .parse() to emit error events for parsing errors.

Test cases are written for only invalid inputs; should be trivial to write tests for valid inputs, but such cases were untested before, tests for them deserve another commit, I suppose.