ES6 and Error Object properties

Kevin Curtis kevinc1846 at googlemail.com
Thu Nov 5 08:13:50 PST 2009


Re standardizing the Error object properties that provide feedback on
the location of the error. (Which can also deal with eval' calls - and
eval calling eval). The stack property in V8 looks informative :

var s = "x = 4; eval('x.open()')";
try {
  z = eval(s);
} catch(e) {
       for (j in e) print("----\n" + j + "\n" + e[j]);
       print("=====\n" + e);
}

Output:-

----
message
Object 4 has no method 'open'
----
stack
TypeError: Object 4 has no method 'open'
   at eval at eval at zz7.js:3:3
   at eval at zz7.js:3:3
   at zz7.js:3:7
----
type
undefined_method
----
arguments
open,4
----
name
TypeError
=======


With //@line functionality line numbers in the eval strings could be
set - and would thus appear in the Error.stack string.

If a location property were adopted it could be nested when eval was called:
print(e.location.location.location.line);
3


More information about the es-discuss mailing list