From 0c417769a78b2d12238c3e7939502a3dd5911ea0 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Fri, 14 Jun 2019 10:00:00 +0200 Subject: [PATCH] Use try/catch --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 53074845a..4482095cc 100644 --- a/index.js +++ b/index.js @@ -106,14 +106,18 @@ function makeAllStream(spawned) { return mixed; } -function getBufferedData(stream, streamPromise) { +async function getBufferedData(stream, streamPromise) { if (!stream) { return; } stream.destroy(); - return streamPromise.catch(error => error.bufferedData); + try { + return await streamPromise; + } catch (error) { + return error.bufferedData; + } } function getStream(process, stream, {encoding, buffer, maxBuffer}) {