Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Returning syntax error location

$
0
0
Hello!

If the stack trace can be retrieved successfully, there should be no need to also retrieve the location string, because the former is a superset of the latter. For example, here's a sample stack trace:
Function expected
    at baz (foo.js:2:28) -> 123()
    at bar (foo.js:5:28) -> baz()
    at foo (foo.js:8:28) -> bar()
    at JScript global code (foo.js:10:24) -> foo()
And here's the location string for the same error:
Function expected
    at (foo.js:2:28) -> 123();
As you can see, the location string is redundant if the stack trace is available. Note that the script engine can detect some errors (such as syntax errors) before it starts executing script code. In that case there's no stack trace, so it makes sense to use the location string.

Thanks!

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>