Product more useful error output when a non-array is produced

master
Sven Slootweg 4 years ago
parent 6a5c558c19
commit 24e90c5330

@ -3,6 +3,7 @@
const Promise = require("bluebird");
const propagateAbort = require("@promistream/propagate-abort");
const unreachable = require("@joepie91/unreachable")("@promistream/buffer");
const util = require("util");
module.exports = function bufferStream() {
let buffer;
@ -20,7 +21,11 @@ module.exports = function bufferStream() {
return attemptRead(readFunc);
}
} else {
throw new Error("Buffered stream produced a non-array value");
// FIXME: Make this its own module, and improve its compactness?
let stringified = util.inspect(result, { depth: 0 })
.replace(/\s+/g, " ");
throw new Error(`Buffered stream produced a non-array value: ${stringified}`);
}
});
}

Loading…
Cancel
Save