-
-
Notifications
You must be signed in to change notification settings - Fork 776
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Starting in Node 7, stack traces are computed eagerly when using Error.captureStackTrace [1]. As a result, the `message` and `name` properties of an error will not be included in the `stack` property if they are set after calling `Error.captureStackTrace`. As a workaround, set the properties before calling `Error.captureStackTrace`. Note that this change in Node was reverted in V8 a few days ago [2], but it will probably be awhile until that fix appears in a Node release. [1] https://chromium.googlesource.com/v8/v8.git/+/4feafee9d9741259e8ec3882fb61935a235ecc54 [2] https://chromium.googlesource.com/v8/v8.git/+/989d7b96f8352b502e2ede62e0b105e143d03837
- Loading branch information
1 parent
d411edd
commit 698f65b
Showing
3 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
|
||
var assert = require('assert'); | ||
var yaml = require('../..'); | ||
var readFileSync = require('fs').readFileSync; | ||
|
||
|
||
test('should include the error message in the error stack', function () { | ||
try { | ||
yaml.safeLoad(readFileSync(require('path').join(__dirname, '/0351.yml'), 'utf8')); | ||
} catch (err) { | ||
assert(err.stack.startsWith('YAMLException: end of the stream or a document separator is expected')); | ||
return; | ||
} | ||
assert.fail(null, null, 'Expected an error to be thrown'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# intentionally invalid yaml | ||
|
||
foo: bar | ||
baz: qux |