@@ -15,7 +15,7 @@ import { assertion, mkdir, pathExists } from './utils';
15
15
import { DryMongoBinary } from './DryMongoBinary' ;
16
16
import { MongoBinaryOpts } from './MongoBinary' ;
17
17
import { clearLine } from 'readline' ;
18
- import { GenericMMSError , Md5CheckFailedError } from './errors' ;
18
+ import { DownloadError , GenericMMSError , Md5CheckFailedError } from './errors' ;
19
19
20
20
const log = debug ( 'MongoMS:MongoBinaryDownload' ) ;
21
21
@@ -416,10 +416,10 @@ export class MongoBinaryDownload {
416
416
if ( response . statusCode != 200 ) {
417
417
if ( response . statusCode === 403 ) {
418
418
reject (
419
- new Error (
419
+ new DownloadError (
420
+ downloadUrl ,
420
421
"Status Code is 403 (MongoDB's 404)\n" +
421
422
"This means that the requested version-platform combination doesn't exist\n" +
422
- ` Used Url: "${ downloadUrl } "\n` +
423
423
"Try to use different version 'new MongoMemoryServer({ binary: { version: 'X.Y.Z' } })'\n" +
424
424
'List of available versions can be found here: ' +
425
425
'https://www.mongodb.com/download-center/community/releases/archive'
@@ -429,12 +429,14 @@ export class MongoBinaryDownload {
429
429
return ;
430
430
}
431
431
432
- reject ( new Error ( `Status Code isnt 200! (it is ${ response . statusCode } )` ) ) ;
432
+ reject (
433
+ new DownloadError ( downloadUrl , `Status Code isnt 200! (it is ${ response . statusCode } )` )
434
+ ) ;
433
435
434
436
return ;
435
437
}
436
438
if ( typeof response . headers [ 'content-length' ] != 'string' ) {
437
- reject ( new Error ( 'Response header "content-length" is empty!' ) ) ;
439
+ reject ( new DownloadError ( downloadUrl , 'Response header "content-length" is empty!' ) ) ;
438
440
439
441
return ;
440
442
}
@@ -453,8 +455,9 @@ export class MongoBinaryDownload {
453
455
! httpOptions . path ?. endsWith ( '.md5' )
454
456
) {
455
457
reject (
456
- new Error (
457
- `Too small (${ this . dlProgress . current } bytes) mongod binary downloaded from ${ downloadUrl } `
458
+ new DownloadError (
459
+ downloadUrl ,
460
+ `Too small (${ this . dlProgress . current } bytes) mongod binary downloaded.`
458
461
)
459
462
) ;
460
463
@@ -477,7 +480,7 @@ export class MongoBinaryDownload {
477
480
. on ( 'error' , ( err : Error ) => {
478
481
// log it without having debug enabled
479
482
console . error ( `Couldnt download "${ downloadUrl } "!` , err . message ) ;
480
- reject ( err ) ;
483
+ reject ( new DownloadError ( downloadUrl , err . message ) ) ;
481
484
} ) ;
482
485
} ) ;
483
486
}
0 commit comments