throw.js
This file
Path
lib/pipe/throw.js
58 lines · 1.5 KiB · JavaScript
Last changed by
Add more code comments (#984)ehmickybefore adoptionfdd8a9f
History of this fileTake it
Rename files (#977)ehmickybefore adoption4b2e316
lines 1–2why, one step back1import {makeEarlyError} from '../return/result.js';2import {abortSourceStream, endDestinationStream} from '../io/pipeline.js';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 3why, one step back3Add more code comments (#984)ehmickybefore adoptionfdd8a9f
lines 4–5why, one step back4// When passing invalid arguments to `source.pipe()`, throw asynchronously.5// We also abort both subprocesses.Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 6–10why, one step back6export const handlePipeArgumentsError = ({7 sourceStream,8 sourceError,9 destinationStream,10 destinationError,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 11why, one step back11 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 12why, one step back12 sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 13why, one step back13 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 14why, one step back14}) => {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 15–20why, one step back15 const error = getPipeArgumentsError({16 sourceStream,17 sourceError,18 destinationStream,19 destinationError,20 });Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 21why, one step back21 if (error !== undefined) {Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 22–27why, one step back22 throw createNonCommandError({23 error,24 fileDescriptors,25 sourceOptions,26 startTime,27 });Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 28–46why, one step back28 }29};3031const getPipeArgumentsError = ({sourceStream, sourceError, destinationStream, destinationError}) => {32 if (sourceError !== undefined && destinationError !== undefined) {33 return destinationError;34 }3536 if (destinationError !== undefined) {37 abortSourceStream(sourceStream);38 return destinationError;39 }4041 if (sourceError !== undefined) {42 endDestinationStream(destinationStream);43 return sourceError;44 }45};46Add more code comments (#984)ehmickybefore adoptionfdd8a9f
line 47why, one step back47// Specific error return value when passing invalid arguments to `subprocess.pipe()` or when using `unpipeSignal`Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 48why, one step back48export const createNonCommandError = ({error, fileDescriptors, sourceOptions, startTime}) => makeEarlyError({Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 49–51why, one step back49 error,50 command: PIPE_COMMAND_MESSAGE,51 escapedCommand: PIPE_COMMAND_MESSAGE,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 52why, one step back52 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 53why, one step back53 options: sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 54why, one step back54 startTime,Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815
line 55why, one step back55 isSync: false,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 56–58why, one step back56});5758const PIPE_COMMAND_MESSAGE = 'source.pipe(destination)';