Improved exception handling for the parser module