Skip to content

Commit

Permalink
Better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 17, 2019
1 parent 0aee82e commit f662166
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/stream/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Buffer } from 'buffer'

import { isValidInput } from '../input.js'
import { execCommand, streamCommand } from '../exec.js'
import { streamError } from '../error.js'
import { streamError, throwError } from '../error.js'

// Decides what to do with the child process result according to `opts.result`:
// - `save`: pushed to `file.execa`
Expand Down Expand Up @@ -50,6 +50,12 @@ const streamResult = function({ file, input, opts, opts: { from } }) {
const execaPromise = streamCommand(input, opts)
const { [from]: stream } = execaPromise

// When `child_process.spawn()` throws synchronously, e.g. on invalid
// option like `{uid: 0.5}`
if (stream === undefined) {
return execaPromise.catch(throwError)
}

// Make stream fail if the command fails
execaPromise.catch(error => streamError(stream, error))

Expand Down

0 comments on commit f662166

Please sign in to comment.