throw.js
This file
Path
lib/pipe/throw.js
45 lines · 1.2 KiB · JavaScript
Last changed by
Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
History of this fileTake it
Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 1why, one step back1import {makeEarlyError} from '../return/error.js';Improve streams pipe logic (#885)ehmickybefore adoption5abc429
line 2why, one step back2import {abortSourceStream, endDestinationStream} from '../stdio/pipeline.js';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 3–8why, one step back34export const handlePipeArgumentsError = ({5 sourceStream,6 sourceError,7 destinationStream,8 destinationError,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 9why, one step back9 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 10why, one step back10 sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 11why, one step back11 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 12–13why, one step back12}) => {13 const error = getPipeArgumentsError({sourceStream, sourceError, destinationStream, destinationError});Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 14why, one step back14 if (error !== undefined) {Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 15why, one step back15 throw createNonCommandError({error, fileDescriptors, sourceOptions, startTime});Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 16–34why, one step back16 }17};1819const getPipeArgumentsError = ({sourceStream, sourceError, destinationStream, destinationError}) => {20 if (sourceError !== undefined && destinationError !== undefined) {21 return destinationError;22 }2324 if (destinationError !== undefined) {25 abortSourceStream(sourceStream);26 return destinationError;27 }2829 if (sourceError !== undefined) {30 endDestinationStream(destinationStream);31 return sourceError;32 }33};34Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 35why, one step back35export const createNonCommandError = ({error, fileDescriptors, sourceOptions, startTime}) => makeEarlyError({Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 36–38why, one step back36 error,37 command: PIPE_COMMAND_MESSAGE,38 escapedCommand: PIPE_COMMAND_MESSAGE,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 39why, one step back39 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 40why, one step back40 options: sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 41why, one step back41 startTime,Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 42why, one step back42 isSync: false,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 43–45why, one step back43});4445const PIPE_COMMAND_MESSAGE = 'source.pipe(destination)';