Skip to content

Commit

Permalink
Use try/catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Jun 14, 2019
1 parent 6e4a43a commit 0c41776
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Expand Up @@ -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}) {
Expand Down

0 comments on commit 0c41776

Please sign in to comment.