From 574dc11a2fed943bc40e338b22c5b12bef66e768 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Fri, 14 Feb 2020 00:31:23 +0200 Subject: vscode: removed nested errors as per matklad --- editors/code/src/installation/download_file.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'editors/code/src/installation') diff --git a/editors/code/src/installation/download_file.ts b/editors/code/src/installation/download_file.ts index 591de0d31..d154f4816 100644 --- a/editors/code/src/installation/download_file.ts +++ b/editors/code/src/installation/download_file.ts @@ -3,7 +3,6 @@ import * as fs from "fs"; import * as stream from "stream"; import * as util from "util"; import { strict as assert } from "assert"; -import { NestedError } from "ts-nested-error"; const pipeline = util.promisify(stream.pipeline); @@ -19,13 +18,13 @@ export async function downloadFile( destFilePermissions: number, onProgress: (readBytes: number, totalBytes: number) => void ): Promise { - const res = await fetch(url).catch(NestedError.rethrow("Failed at initial fetch")); + const res = await fetch(url); if (!res.ok) { console.log("Error", res.status, "while downloading file from", url); console.dir({ body: await res.text(), headers: res.headers }, { depth: 3 }); - throw new NestedError(`Got response ${res.status}`); + throw new Error(`Got response ${res.status} when trying to download a file.`); } const totalBytes = Number(res.headers.get('content-length')); @@ -41,7 +40,7 @@ export async function downloadFile( const destFileStream = fs.createWriteStream(destFilePath, { mode: destFilePermissions }); - await pipeline(res.body, destFileStream).catch(NestedError.rethrow("Piping file error")); + await pipeline(res.body, destFileStream); return new Promise(resolve => { destFileStream.on("close", resolve); destFileStream.destroy(); -- cgit v1.2.3