marook / osm-read

an openstreetmap XML and PBF data parser for node.js and the browser
GNU Lesser General Public License v3.0
107 stars 25 forks source link

fix parser doesn't exist error #24

Closed missinglink closed 10 years ago

missinglink commented 10 years ago

In the case where an err is returned and parser is null; we should check for the existence of parser before calling it.

This is currently throwing for me:

osm-read/lib/pbfParser.js:464
                parser.close();
                       ^
TypeError: Cannot call method 'close' of undefined
    at fail (osm-read/lib/pbfParser.js:464:24)
    at Object.createPathParser.callback (osm-read/lib/pbfParser.js:470:24)
    at osm-read/lib/pbfParser.js:409:29
    at osm-read/lib/pbfParser.js:350:20
    at osm-read/lib/pbfParser.js:66:28
    at osm-read/lib/pbfParser.js:42:24
    at bytesReadFail (osm-read/lib/nodejs/fsReader.js:5:12)
    at osm-read/lib/nodejs/fsReader.js:33:20
    at Object.wrapper [as oncomplete] (fs.js:454:17)
missinglink commented 10 years ago

had to close this because github wouldn't let me change the PR base. see https://github.com/marook/osm-read/pull/25 for the correct diff