From 9d13b2339f426a7cd4c0bf84503f9325a398e47a Mon Sep 17 00:00:00 2001 From: Kevin Kwok Date: Fri, 14 Oct 2016 01:38:51 -0400 Subject: [PATCH] catching errors --- src/browser/lang.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/browser/lang.js b/src/browser/lang.js index 4093acd..f87b0d1 100644 --- a/src/browser/lang.js +++ b/src/browser/lang.js @@ -14,8 +14,11 @@ module.exports = function getLanguageData(req, res, cb){ var lang = req.options.lang; function saveDataFile(data){ - db.put(lang, data, err => console.log('cached', lang, err)) - cb(data) + try { + db.put(lang, data, err => console.log('cached', lang, err)) + } finally { + cb(data) + } } db.open({ compression: false }, err => {