Skip to content
Myr

Fix stack trace workaround (#818)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by ehmicky · committed by GitHub · parent fa04e3c · Browse files · 2 files+14 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+14 added−6 removed

  • tests:+9 added−1 removed
  • other:+5 added−5 removed

2 files+14 added−6 removed

modified:lib/clone.js+5 added-5 removed
modified:test/clone.js+9 added-1 removed
118 unmodified lines
119 const childProcess = execa('empty.js');120 childProcess.emit('error', error);121 t.is(await t.throwsAsync(childProcess), error);122 t.is(error.message, `Command failed: empty.js\n${message}`);123 t.true(error.stack.startsWith(`Error: Command failed: empty.js\n${message}`));123 t.true(error.stack.startsWith(`Error: ${error.message}`));124});125126test('error.stack is set even if memoized with an unusual error.name', async t => {127 const childProcess = execa('empty.js');128 childProcess.stdin.destroy();129 const error = await t.throwsAsync(childProcess);130 t.is(error.message, 'Command failed with ERR_STREAM_PREMATURE_CLOSE: empty.js\nPremature close');131 t.true(error.stack.startsWith(`Error [ERR_STREAM_PREMATURE_CLOSE]: ${error.message}`));132});133134test('Cloned errors keep the stack trace', async t => {135 const message = 'test';136 const error = new Error(message);137 const stack = error.stack.split('\n').filter(line => line.trim().startsWith('at ')).join('\n');
13 unmodified lines