move callback outside of try / catch

it's dangerous to callback inside try, because you may catch unexpected throws in callback.
master
Dominic Tarr 2011-06-12 15:45:02 -07:00
parent ae5aec6830
commit 6c6887a850
1 changed files with 3 additions and 2 deletions

View File

@ -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);
});
};