@@ -3,7 +3,6 @@ import * as fs from "fs";
33import * as stream from "stream" ;
44import * as util from "util" ;
55import { strict as assert } from "assert" ;
6- import { NestedError } from "ts-nested-error" ;
76
87const pipeline = util . promisify ( stream . pipeline ) ;
98
@@ -19,13 +18,13 @@ export async function downloadFile(
1918 destFilePermissions : number ,
2019 onProgress : ( readBytes : number , totalBytes : number ) => void
2120) : Promise < void > {
22- const res = await fetch ( url ) . catch ( NestedError . rethrow ( "Failed at initial fetch" ) ) ;
21+ const res = await fetch ( url ) ;
2322
2423 if ( ! res . ok ) {
2524 console . log ( "Error" , res . status , "while downloading file from" , url ) ;
2625 console . dir ( { body : await res . text ( ) , headers : res . headers } , { depth : 3 } ) ;
2726
28- throw new NestedError ( `Got response ${ res . status } ` ) ;
27+ throw new Error ( `Got response ${ res . status } when trying to download a file. ` ) ;
2928 }
3029
3130 const totalBytes = Number ( res . headers . get ( 'content-length' ) ) ;
@@ -41,7 +40,7 @@ export async function downloadFile(
4140
4241 const destFileStream = fs . createWriteStream ( destFilePath , { mode : destFilePermissions } ) ;
4342
44- await pipeline ( res . body , destFileStream ) . catch ( NestedError . rethrow ( "Piping file error" ) ) ;
43+ await pipeline ( res . body , destFileStream ) ;
4544 return new Promise < void > ( resolve => {
4645 destFileStream . on ( "close" , resolve ) ;
4746 destFileStream . destroy ( ) ;
0 commit comments