Skip to content
Myr

Make errors more consistent (#266)

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

authored by ehmicky · committed by Sindre Sorhus · parent 6853316 · Browse files · 2 files+19 added−1 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+19 added−1 removed

  • other:+19 added−1 removed

2 files+19 added−1 removed

modified:index.js+7 added-1 removed
216 unmodified lines
217 let spawned;218 try {219 spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);220 } catch (error) {221 return Promise.reject(error);221 return Promise.reject(makeError({error, stdout: '', stderr: '', all: ''}, {222 joinedCommand,223 parsed,224 timedOut: false,225 isCanceled: false,226 killed: false227 }));228 }229230 // #115231 let removeExitHandler;
234 unmodified lines
modified:test.js+12 added
215 unmodified lines
216 t.is(typeof kill, 'function');217 t.is(typeof pid, 'number');218});219220test('child_process.spawn() errors are propagated', async t => {221 const {exitCodeName} = await t.throwsAsync(execa('noop', {uid: -1}));222 t.is(exitCodeName, process.platform === 'win32' ? 'ENOTSUP' : 'EINVAL');223});224225test('child_process.spawnSync() errors are propagated', t => {226 const {exitCodeName} = t.throws(() => {227 execa.sync('noop', {uid: -1});228 });229 t.is(exitCodeName, process.platform === 'win32' ? 'ENOTSUP' : 'EINVAL');230});231232test('maxBuffer affects stdout', async t => {233 await t.throwsAsync(execa('max-buffer', ['stdout', '11'], {maxBuffer: 10}), /stdout maxBuffer exceeded/);234 await t.notThrowsAsync(execa('max-buffer', ['stdout', '10'], {maxBuffer: 10}));235});
494 unmodified lines