Make error messages from require() more useful

This commit is contained in:
Jason Kohles 2014-03-13 14:18:45 -04:00
parent 5bec691575
commit 45217a0953

View file

@ -244,7 +244,9 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
try {
compiledWrapper = eval(code);
} catch (e) {
throw 'Error:' + e + ' while evaluating module ' + canonizedFilename;
throw new Error( "Error evaluating module " + path
+ " at " + canonizedFilename + " line #" + e.lineNumber
+ ". Error was: " + e.message, canonizedFilename, e.lineNumber );
}
var __dirname = '' + file.parentFile.canonicalPath;
var parameters = [
@ -259,7 +261,9 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
.apply(moduleInfo.exports, /* this */
parameters);
} catch (e) {
throw 'Error:' + e + ' while executing module ' + canonizedFilename;
throw new Error( "Error executing module " + path
+ " at " + canonizedFilename + " line #" + e.lineNumber
+ ". Error was: " + e.message, canonizedFilename, e.lineNumber )
}
if ( hooks ) {
hooks.loaded( canonizedFilename );