Skip to content
Myr

Make the synchronous errors code clearer (#331)

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 46daa7b · Browse files · 2 files+25 added−21 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+25 added−21 removed

  • other:+25 added−21 removed

2 files+25 added−21 removed

modified:lib/promise.js+11 added-8 removed
modified:index.js+14 added-13 removed
76 unmodified lines
77 let spawned;78 try {79 spawned = childProcess.spawn(parsed.file, parsed.args, parsed.options);80 } catch (error) {81 // Ensure the returned error is always both a promise and a child process81 return mergePromise(new childProcess.ChildProcess(), () =>82 Promise.reject(makeError({83 error,84 stdout: '',85 stderr: '',86 all: '',87 command,88 parsed,89 timedOut: false,90 isCanceled: false,91 killed: false92 }))93 );82 const dummySpawned = new childProcess.ChildProcess();83 const errorPromise = Promise.reject(makeError({84 error,85 stdout: '',86 stderr: '',87 all: '',88 command,89 parsed,90 timedOut: false,91 isCanceled: false,92 killed: false93 }));94 return mergePromise(dummySpawned, errorPromise);95 }9697 const context = {timedOut: false, isCanceled: false};98
158 unmodified lines