diff --git a/src/enum.js b/src/enum.js index c847fceda..cc797a68e 100644 --- a/src/enum.js +++ b/src/enum.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); diff --git a/src/root.js b/src/root.js index 7d19f4b1e..dbedb805f 100644 --- a/src/root.js +++ b/src/root.js @@ -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; }