forward zlib decompression errors instead of failing hard

This commit is contained in:
Konstantin Käfer
2011-05-12 16:24:40 -04:00
parent f92d754816
commit 9cb9ad771d
+5
View File
@@ -231,6 +231,8 @@ MBTiles.prototype.grid = function(x, y, z, callback) {
function(err, row, rows) {
if (err) return callback(err);
if (!row || !row.grid) return callback('Grid does not exist');
try {
var grid = zlib.inflate(
!Buffer.isBuffer(row.grid)
? new Buffer(row.grid, 'binary')
@@ -241,6 +243,9 @@ MBTiles.prototype.grid = function(x, y, z, callback) {
return memo;
}, {});
callback(null, _(JSON.parse(grid)).extend({ data: data }));
} catch(err) {
callback(err);
}
}
);
};