mirror of https://github.com/nodejs/node.git
require() should throw error if module does.
Reported by Kris Zyp http://groups.google.com/group/nodejs/browse_thread/thread/1feab0309bd5402bv0.7.4-release
parent
4526308560
commit
bfa36136da
|
@ -892,7 +892,12 @@ Module.prototype.loadScript = function (filename, loadPromise) {
|
|||
+ "\n}; __wrap__;";
|
||||
var compiledWrapper = process.compile(wrapper, filename);
|
||||
|
||||
compiledWrapper.apply(self.exports, [self.exports, require, self, filename]);
|
||||
try {
|
||||
compiledWrapper.apply(self.exports, [self.exports, require, self, filename]);
|
||||
} catch (e) {
|
||||
loadPromise.emitError(e);
|
||||
return;
|
||||
}
|
||||
|
||||
self.waitChildrenLoad(function () {
|
||||
self.loaded = true;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
throw new Error("blah");
|
|
@ -33,6 +33,14 @@ assert.equal("D", d3.D());
|
|||
assert.equal(true, d4.D instanceof Function);
|
||||
assert.equal("D", d4.D());
|
||||
|
||||
var errorThrown = false;
|
||||
try {
|
||||
require("./fixtures/throws_error");
|
||||
} catch (e) {
|
||||
errorThrown = true;
|
||||
assert.equal("blah", e.message);
|
||||
}
|
||||
|
||||
process.addListener("exit", function () {
|
||||
assert.equal(true, a.A instanceof Function);
|
||||
assert.equal("A done", a.A());
|
||||
|
@ -49,5 +57,7 @@ process.addListener("exit", function () {
|
|||
assert.equal(true, d2.D instanceof Function);
|
||||
assert.equal("D done", d2.D());
|
||||
|
||||
assert.equal(true, errorThrown);
|
||||
|
||||
puts("exit");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue