Huemul / chimi

Validate JavaScript code from your README
https://github.com/Huemul/chimi
33 stars 0 forks source link

Handle stack-traces #20

Closed fvictorio closed 7 years ago

fvictorio commented 7 years ago

If a part of the snippet throws an error, things work fine (the line that caused the error is printed).

But if we have something like this:

```js
const foo = 42

assert(foo <= 40)

console.log('I like my foos small and manageable')

The output is:

Errors

// ----- README.md -----

// --- Snippet #0 in README.md --- assert.js:60 throw new errors.AssertionError({ ^

AssertionError [ERR_ASSERTION]: false == true at [stdin]:6:1 at ContextifyScript.Script.runInThisContext (vm.js:44:33) at Object.runInThisContext (vm.js:116:38) at Object. ([stdin]-wrapper:6:22) at Module._compile (module.js:569:30) at evalScript (bootstrap_node.js:432:27) at Socket. (bootstrap_node.js:198:15) at emitNone (events.js:110:20) at Socket.emit (events.js:207:7) at endReadableNT (_stream_readable.js:1045:12)



Notice the `[stdin]:6`. Maybe that gives us the line of the snippet. The actual line is the third one, but it has an added dependency (assert) that moves it down, so that may be causing the shift.
gillchristian commented 7 years ago

26