Refactored error handling mechanisms for parsing.

- This is needed to make passing error handling devices into more pieces of the parser easy.

#210

/cc @pranavkm