Skip to content

Commit 5915ff9

Browse files
committed
Do not swallow errors in loadSync, also accept negative enum values in Enum#add, fixes #609
1 parent bcadffe commit 5915ff9

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/enum.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ EnumPrototype.add = function(name, id) {
9494
if (!util.isString(name))
9595
throw TypeError("name must be a string");
9696
/* istanbul ignore next */
97-
if (!util.isInteger(id) || id < 0)
98-
throw TypeError("id must be a non-negative integer");
97+
if (!util.isInteger(id))
98+
throw TypeError("id must be an integer");
9999
/* istanbul ignore next */
100100
if (this.values[name] !== undefined)
101101
throw Error("duplicate name '" + name + "' in " + this);

src/root.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ RootPrototype.load = function load(filename, options, callback) {
8888
var self = this;
8989
if (!callback)
9090
return util.asPromise(load, self, filename);
91+
92+
var sync = callback === SYNC; // undocumented
9193

9294
// Finishes loading by calling the callback (exactly once)
9395
function finish(err, root) {
@@ -98,8 +100,6 @@ RootPrototype.load = function load(filename, options, callback) {
98100
cb(err, root);
99101
}
100102

101-
var sync = callback === SYNC; // undocumented
102-
103103
// Processes a single file
104104
function process(filename, source) {
105105
try {
@@ -120,6 +120,8 @@ RootPrototype.load = function load(filename, options, callback) {
120120
});
121121
}
122122
} catch (err) {
123+
if (sync)
124+
throw err;
123125
finish(err);
124126
return;
125127
}

0 commit comments

Comments
 (0)