From 342f582c2176776eed1b3be3fac0d4ac20020189 Mon Sep 17 00:00:00 2001 From: Will White Date: Thu, 16 Aug 2012 09:29:32 -0400 Subject: [PATCH] Be less strict when reading metadata. If the metadata table or the requested field is missing return null and allow the caller handle it. --- lib/mbtiles.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/mbtiles.js b/lib/mbtiles.js index 220ec1e..8c81335 100644 --- a/lib/mbtiles.js +++ b/lib/mbtiles.js @@ -247,7 +247,9 @@ MBTiles.prototype._metadata = function(key, callback) { this._db.get('SELECT value FROM metadata WHERE name = ?', key, function(err, row) { - if (!row || (err && err.errno == 1)) return callback(new Error('Key does not exist')); + // If the metadata table or the requested field is missing return + // null and allow the caller handle it. + if (!row || (err && err.errno == 1)) return callback(null, null); else if (err) return callback(err); else return callback(null, row.value); });