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 {
|
try {
|
||||||
compiledWrapper = eval(code);
|
compiledWrapper = eval(code);
|
||||||
} catch (e) {
|
} 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 __dirname = '' + file.parentFile.canonicalPath;
|
||||||
var parameters = [
|
var parameters = [
|
||||||
|
@ -259,7 +261,9 @@ When resolving module names to file paths, ScriptCraft uses the following rules.
|
||||||
.apply(moduleInfo.exports, /* this */
|
.apply(moduleInfo.exports, /* this */
|
||||||
parameters);
|
parameters);
|
||||||
} catch (e) {
|
} 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 ) {
|
if ( hooks ) {
|
||||||
hooks.loaded( canonizedFilename );
|
hooks.loaded( canonizedFilename );
|
||||||
|
|
Reference in a new issue