move callback outside of try / catch
it's dangerous to callback inside try, because you may catch unexpected throws in callback.
This commit is contained in:
parent
ae5aec6830
commit
6c6887a850
1 changed files with 3 additions and 2 deletions
|
@ -97,12 +97,13 @@ File.prototype.load = function (callback) {
|
|||
|
||||
try {
|
||||
self.store = self.format.parse(data.toString());
|
||||
callback(null, self.store);
|
||||
}
|
||||
catch (ex) {
|
||||
self.store = {};
|
||||
callback(ex);
|
||||
return callback(ex);
|
||||
}
|
||||
callback(null, self.store);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue