forward zlib decompression errors instead of failing hard
This commit is contained in:
@@ -231,16 +231,21 @@ 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');
|
||||
var grid = zlib.inflate(
|
||||
!Buffer.isBuffer(row.grid)
|
||||
? new Buffer(row.grid, 'binary')
|
||||
: row.grid
|
||||
).toString();
|
||||
var data = rows.reduce(function(memo, r) {
|
||||
memo[r.key_name] = JSON.parse(r.key_json);
|
||||
return memo;
|
||||
}, {});
|
||||
callback(null, _(JSON.parse(grid)).extend({ data: data }));
|
||||
|
||||
try {
|
||||
var grid = zlib.inflate(
|
||||
!Buffer.isBuffer(row.grid)
|
||||
? new Buffer(row.grid, 'binary')
|
||||
: row.grid
|
||||
).toString();
|
||||
var data = rows.reduce(function(memo, r) {
|
||||
memo[r.key_name] = JSON.parse(r.key_json);
|
||||
return memo;
|
||||
}, {});
|
||||
callback(null, _(JSON.parse(grid)).extend({ data: data }));
|
||||
} catch(err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user