Skip to content
Myr

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 file

Take it

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

line 1why, one step back
1import {makeEarlyError} from '../return/error.js';

Improve streams pipe logic (#885)ehmickybefore adoption5abc429

line 2why, one step back
2import {abortSourceStream, endDestinationStream} from '../stdio/pipeline.js';

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

lines 3–8why, one step back
3
4export const handlePipeArgumentsError = ({5 sourceStream,6 sourceError,7 destinationStream,8 destinationError,

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 9why, one step back
9 fileDescriptors,

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

line 10why, one step back
10 sourceOptions,

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

line 11why, one step back
11 startTime,

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

lines 12–13why, one step back
12}) => {
13 const error = getPipeArgumentsError({sourceStream, sourceError, destinationStream, destinationError});

Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86

line 14why, one step back
14 if (error !== undefined) {

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 15why, one step back
15 throw createNonCommandError({error, fileDescriptors, sourceOptions, startTime});

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

lines 16–34why, one step back
16 }
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};34

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 35why, one step back
35export const createNonCommandError = ({error, fileDescriptors, sourceOptions, startTime}) => makeEarlyError({

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

lines 36–38why, one step back
36 error,
37 command: PIPE_COMMAND_MESSAGE,38 escapedCommand: PIPE_COMMAND_MESSAGE,

Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d

line 39why, one step back
39 fileDescriptors,

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

line 40why, one step back
40 options: sourceOptions,

Add `result|error.durationMs` (#896)ehmickybefore adoption7088091

line 41why, one step back
41 startTime,

Add `ExecaError` and `ExecaSyncError` classes (#911)ehmickybefore adoptionfc01815

line 42why, one step back
42 isSync: false,

Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4

lines 43–45why, one step back
43});
4445const PIPE_COMMAND_MESSAGE = 'source.pipe(destination)';