summaryrefslogtreecommitdiff
path: root/lib/module.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/module.js')
-rw-r--r--lib/module.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/module.js b/lib/module.js
index 8feba15b0f..82b1971e8b 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -23,6 +23,16 @@ function hasOwnProperty(obj, prop) {
}
+function tryWrapper(wrapper, opts) {
+ try {
+ return runInThisContext(wrapper, opts);
+ } catch (e) {
+ internalUtil.decorateErrorStack(e);
+ throw e;
+ }
+}
+
+
function Module(id, parent) {
this.id = id;
this.exports = {};
@@ -371,8 +381,8 @@ Module.prototype._compile = function(content, filename) {
// create wrapper function
var wrapper = Module.wrap(content);
- var compiledWrapper = runInThisContext(wrapper,
- { filename: filename, lineOffset: 0 });
+ var compiledWrapper = tryWrapper(wrapper,
+ { filename: filename, lineOffset: 0 });
if (global.v8debug) {
if (!resolvedArgv) {
// we enter the repl if we're not given a filename argument.