diff --git a/.travis.yml b/.travis.yml index bc50d38..025a1d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - '0.10' -- '0.12' +- '4.2.3' addons: apt: sources: diff --git a/index.js b/index.js index 08aa03c..5b1be93 100644 --- a/index.js +++ b/index.js @@ -341,7 +341,10 @@ Vector.prototype.profile = function(callback) { if (queue.length) { var t = queue.shift(); s.getTile(t.z, t.x, t.y, function(err, run1, headers) { - if (err) return callback(err); + if (err) { + err.code = 'EMAPNIK'; + return callback(err); + } s.getTile(t.z, t.x, t.y, function(err, run2, headers) { if (err) return callback(err); t.drawtime = Math.min(run1._drawtime, run2._drawtime); diff --git a/test/fixtures/tm2z/invalid.tm2z b/test/fixtures/tm2z/invalid.tm2z new file mode 100644 index 0000000..d3c3d5b Binary files /dev/null and b/test/fixtures/tm2z/invalid.tm2z differ diff --git a/test/tm2z.js b/test/tm2z.js index 7eb8a2f..dc93381 100644 --- a/test/tm2z.js +++ b/test/tm2z.js @@ -179,7 +179,7 @@ test('errors out if unzipped project.xml size exceeds custom max size', function }); test('errors out if not a directory', function(t) { tilelive.load('tm2z://' + path.join(fixtureDir, 'nodirectory.tm2z'), function(err, source) { - t.equal(err.message.split(',')[0], 'EISDIR'); + t.ok(err.message.indexOf('EISDIR') !== -1); t.end(); }); }); @@ -250,6 +250,16 @@ test('profiles a tm2z file', function(t) { }); }); }); +test('errors with EMAPNIK when profiling invalid tm2z', function(t) { + tilelive.load('tm2z://' + path.join(fixtureDir, 'invalid.tm2z'), function(err, source) { + t.ifError(err); + source.profile(function(err, profile) { + t.equal('EMAPNIK', err.code); + t.equal(err.message, 'Tile does not exist'); + t.end(); + }); + }); +}); test('loads a tm2z+http url', function(t) { tilelive.load('tm2z+' + remotePath, function(err, source) {