codehag / js-better-errors

Let's discuss making better errors for JavaScript
MIT License
37 stars 2 forks source link

standardized error.stack #13

Open nuxodin opened 4 years ago

nuxodin commented 4 years ago

I don't know if this project is aimed at the "stack" property, but I would hope to see progress there.

What is the code triggering the message?

function test (){
  console.log(new Error().stack+'')
}
function doit(){
  test()
}
doit();

What error message do you see? Which JavaScript environment produced this error?

spidermonkey:

test@https://example.com/main.js:2:14
doit@https://example.com/main.js:5:2
@https://example.com//main.js:7:1

jsc:

test@https://example.com/main.js:2:14 
doit@https://example.com/main.js:5:2 
global code@https://example.com/main.js:7:1

v8:

Error
    at test (https://example.com/main.js:2:14)
    at doit (https://example.com/main.js:5:2)
    at https://example.com/main.js:7:1

What error message would you like to see?

I would like a standardized stack property, if possibliy as a array error.stackArray

[{
       function: 'test',
       file: 'https://example.com/main.js',
       line: 2,
       column: 14
},{
       function: 'doit',
       file: 'https://example.com/main.js',
       line: 5,
       column: 2
},{
       function: Error.STACK_GLOBAL_SCOPE,
       file: 'https://example.com/main.js',
       line: 7,
       column: 1
}]

Do you agree to license your suggested error message under an MIT-style license?

Yes