Permalink
Browse files

Do not swallow errors in loadSync, also accept negative enum values i…

…n Enum#add, fixes #609
  • Loading branch information...
dcodeIO committed Jan 3, 2017
1 parent bcadffe commit 5915ff972482e7db2a73629244ab8a93685b2e55
Showing with 6 additions and 4 deletions.
  1. +2 −2 src/enum.js
  2. +4 −2 src/root.js
@@ -94,8 +94,8 @@ EnumPrototype.add = function(name, id) {
if (!util.isString(name))
throw TypeError("name must be a string");
/* istanbul ignore next */
if (!util.isInteger(id) || id < 0)
throw TypeError("id must be a non-negative integer");
if (!util.isInteger(id))
throw TypeError("id must be an integer");
/* istanbul ignore next */
if (this.values[name] !== undefined)
throw Error("duplicate name '" + name + "' in " + this);
@@ -88,6 +88,8 @@ RootPrototype.load = function load(filename, options, callback) {
var self = this;
if (!callback)
return util.asPromise(load, self, filename);
var sync = callback === SYNC; // undocumented
// Finishes loading by calling the callback (exactly once)
function finish(err, root) {
@@ -98,8 +100,6 @@ RootPrototype.load = function load(filename, options, callback) {
cb(err, root);
}
var sync = callback === SYNC; // undocumented
// Processes a single file
function process(filename, source) {
try {
@@ -120,6 +120,8 @@ RootPrototype.load = function load(filename, options, callback) {
});
}
} catch (err) {
if (sync)
throw err;
finish(err);
return;
}

0 comments on commit 5915ff9

Please sign in to comment.