Skip to content

Commit

Permalink
Merge pull request perliedman#28 from donnut/develop
Browse files Browse the repository at this point in the history
handles invalid or unreachable overpassUrl
  • Loading branch information
perliedman authored Nov 12, 2017
2 parents edd3377 + 087111b commit 5f9e448
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ module.exports = function(query, cb, options) {
});
}

r.on('error', cb);

return r;
};
9 changes: 9 additions & 0 deletions test/specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ test('can execute basic query', function(t) {
});
});

test('can not resolve overpass url', function(t) {
queryOverpass('[out:json];node(57.7,11.9,57.8,12.0)[amenity=bar];out;', function(err, geojson) {
t.ok(err, 'Should return an error');
t.equal(err.message, 'getaddrinfo ENOTFOUND unknown_domain unknown_domain:80', 'Should return the proper error message');
t.end();

}, { overpassUrl: 'http://unknown_domain/api/interpreter' });
});

test('can flatten properties', function(t) {
queryOverpass('[out:json];node(57.7,11.9,57.8,12.0)[amenity=restaurant];out;', function(err, geojson) {
if (err) {
Expand Down

0 comments on commit 5f9e448

Please sign in to comment.