@@ -3,7 +3,6 @@ import * as fs from "fs";
3
3
import * as stream from "stream" ;
4
4
import * as util from "util" ;
5
5
import { strict as assert } from "assert" ;
6
- import { NestedError } from "ts-nested-error" ;
7
6
8
7
const pipeline = util . promisify ( stream . pipeline ) ;
9
8
@@ -19,13 +18,13 @@ export async function downloadFile(
19
18
destFilePermissions : number ,
20
19
onProgress : ( readBytes : number , totalBytes : number ) => void
21
20
) : Promise < void > {
22
- const res = await fetch ( url ) . catch ( NestedError . rethrow ( "Failed at initial fetch" ) ) ;
21
+ const res = await fetch ( url ) ;
23
22
24
23
if ( ! res . ok ) {
25
24
console . log ( "Error" , res . status , "while downloading file from" , url ) ;
26
25
console . dir ( { body : await res . text ( ) , headers : res . headers } , { depth : 3 } ) ;
27
26
28
- throw new NestedError ( `Got response ${ res . status } ` ) ;
27
+ throw new Error ( `Got response ${ res . status } when trying to download a file. ` ) ;
29
28
}
30
29
31
30
const totalBytes = Number ( res . headers . get ( 'content-length' ) ) ;
@@ -41,7 +40,7 @@ export async function downloadFile(
41
40
42
41
const destFileStream = fs . createWriteStream ( destFilePath , { mode : destFilePermissions } ) ;
43
42
44
- await pipeline ( res . body , destFileStream ) . catch ( NestedError . rethrow ( "Piping file error" ) ) ;
43
+ await pipeline ( res . body , destFileStream ) ;
45
44
return new Promise < void > ( resolve => {
46
45
destFileStream . on ( "close" , resolve ) ;
47
46
destFileStream . destroy ( ) ;
0 commit comments