fixed error-report within translator.js

reported by [rex-huang](https://community.nodebb.org/user/rex-huang), see https://community.nodebb.org/topic/4520/error-handling-is-wrong-in-translator-js
This commit is contained in:
Ole R.
2015-05-21 15:38:19 +02:00
parent 927971b392
commit 22e227a6cd

View File

@@ -283,11 +283,12 @@
}
try {
callback(JSON.parse(data.toString()));
data = JSON.parse(data.toString());
} catch (e) {
winston.error('Could not parse `' + filename + '.json`, syntax error? Skipping...');
callback({});
data = {};
}
callback(data);
});
}
@@ -307,4 +308,4 @@
typeof exports === 'object' ? exports :
typeof define === 'function' && define.amd ? {} :
translator = {}
);
);