Make error messages from require() more useful
This commit is contained in:
parent
5bec691575
commit
45217a0953
1 changed files with 6 additions and 2 deletions
|
@ -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 );
|
||||
|
|
Reference in a new issue