Detect non-streams and improve error reporting

master
Sven Slootweg 3 years ago
parent ed2879e5fc
commit 3bcdcbcd08

@ -16,13 +16,17 @@ module.exports = function pipe(streams) {
function getPipeline(source) {
if (!boundPipelineCache.has(source)) {
let pipeline = existentStreams.reduce((bound, stream) => {
if (stream.read == null) {
throw new Error(`Stream is missing a read handler (stream description: ${stream.description})`);
let pipeline = existentStreams.reduce((bound, stream, i) => {
// TODO: Use Validatem for this instead
// FIXME: Stream index is currently wrong if there were any nulls in the streams list, correct for this
if (!(typeof stream === "object") || Array.isArray(stream)) {
throw new Error(`Value at index ${i} in the pipeline is not a stream`);
} else if (stream.read == null) {
throw new Error(`Stream at index ${i} is missing a read handler (stream description: ${stream.description})`);
} else if (stream.abort == null) {
throw new Error(`Stream is missing an abort handler (stream description: ${stream.description})`);
throw new Error(`Stream at index ${i} is missing an abort handler (stream description: ${stream.description})`);
} else if (stream.peek == null) {
throw new Error(`Stream is missing a peek handler (stream description: ${stream.description})`);
throw new Error(`Stream at index ${i} is missing a peek handler (stream description: ${stream.description})`);
} else {
if (bound != null) {
return Object.assign({}, stream, {

Loading…
Cancel
Save