Skip to content

Commit

Permalink
Do not swallow errors in loadSync, also accept negative enum values i…
Browse files Browse the repository at this point in the history
…n Enum#add, fixes #609
  • Loading branch information
dcodeIO committed Jan 3, 2017
1 parent bcadffe commit 5915ff9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/enum.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -120,6 +120,8 @@ RootPrototype.load = function load(filename, options, callback) {
});
}
} catch (err) {
if (sync)
throw err;
finish(err);
return;
}
Expand Down

0 comments on commit 5915ff9

Please sign in to comment.