-
Type:
Improvement
-
Resolution: Done
-
Priority:
Minor - P4
-
Affects Version/s: None
-
Component/s: JavaScript
-
None
-
Fully Compatible
-
Platforms 2016-09-19
-
None
-
0
-
None
-
None
-
None
-
None
-
None
-
None
If you use load() in a js file to load another js file with syntax errors, the interpreter may sometimes not print the line where the syntax error is, due to the way we have implemented the load() function.
For example:
1.js
load("2.js");
2.js
// this is 2 // // ..................)
Running 2.js by itself works properly and gives the exact line and column of the error:
/data/m/ent/mongo: ./mongo 2.js --nodb MongoDB shell version: 0.0.0 2016-03-14T17:07:27.632-0400 E QUERY [thread1] SyntaxError: expected rest argument name, got '...' @2.js:4:3 failed to load: 2.js
Running 1.js loses context – no way to know where the error is:
/data/m/ent/mongo: ./mongo 1.js --nodb MongoDB shell version: 0.0.0 2016-03-14T17:07:33.644-0400 E QUERY [thread1] SyntaxError: expected rest argument name, got '...' : @1.js:1:1 2016-03-14T17:07:33.644-0400 E QUERY [thread1] Error: error loading js file: 2.js : @1.js:1:1 failed to load: 1.js
I have noticed, however, that Reference Errors do not suffer from this, and always print the context even if they are nested within load().