Fix the bug of not capturing scanner error

YAML parser generates ScannerError and ParserError. Previously just the
parser errors are captured, now the others are added.