Print error to console when fail to parse.

Minor re-factoring.