[SERVER-23135] js load() loses context on Syntax Errors Created: 14/Mar/16 Updated: 19/Nov/16 Resolved: 15/Sep/16 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript |
| Affects Version/s: | None |
| Fix Version/s: | 3.3.14 |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Eric Milkie | Assignee: | Matt Cotter |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Platforms 2016-09-19 |
| Participants: |
| Description |
|
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
2.js
Running 2.js by itself works properly and gives the exact line and column of the error:
Running 1.js loses context – no way to know where the error is:
I have noticed, however, that Reference Errors do not suffer from this, and always print the context even if they are nested within load(). |
| Comments |
| Comment by Githook User [ 15/Sep/16 ] |
|
Author: {u'username': u'Machyne', u'name': u'Matt Cotter', u'email': u'matt.cotter@mongodb.com'}Message: This patch ensures that we print the correct filename and line number |
| Comment by Eric Milkie [ 09/Sep/16 ] |
|
Matt and I noticed that the command line spidermonkey client prints the file and line number for syntax errors (although their call stack is still missing frames just like ours!). So we are looking into doing the same thing for the mongo js shell. |
| Comment by Eric Milkie [ 09/Sep/16 ] |
|
(Example is calling a function that isn't defined.) |
| Comment by Matt Cotter [ 09/Sep/16 ] |
|
milkie - what did you mean by
Can you add an example? |