@@ -15,7 +15,7 @@ import { assertion, mkdir, pathExists } from './utils';
1515import { DryMongoBinary } from './DryMongoBinary' ;
1616import { MongoBinaryOpts } from './MongoBinary' ;
1717import { clearLine } from 'readline' ;
18- import { GenericMMSError , Md5CheckFailedError } from './errors' ;
18+ import { DownloadError , GenericMMSError , Md5CheckFailedError } from './errors' ;
1919
2020const log = debug ( 'MongoMS:MongoBinaryDownload' ) ;
2121
@@ -416,10 +416,10 @@ export class MongoBinaryDownload {
416416 if ( response . statusCode != 200 ) {
417417 if ( response . statusCode === 403 ) {
418418 reject (
419- new Error (
419+ new DownloadError (
420+ downloadUrl ,
420421 "Status Code is 403 (MongoDB's 404)\n" +
421422 "This means that the requested version-platform combination doesn't exist\n" +
422- ` Used Url: "${ downloadUrl } "\n` +
423423 "Try to use different version 'new MongoMemoryServer({ binary: { version: 'X.Y.Z' } })'\n" +
424424 'List of available versions can be found here: ' +
425425 'https://www.mongodb.com/download-center/community/releases/archive'
@@ -429,12 +429,14 @@ export class MongoBinaryDownload {
429429 return ;
430430 }
431431
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+ ) ;
433435
434436 return ;
435437 }
436438 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!' ) ) ;
438440
439441 return ;
440442 }
@@ -453,8 +455,9 @@ export class MongoBinaryDownload {
453455 ! httpOptions . path ?. endsWith ( '.md5' )
454456 ) {
455457 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.`
458461 )
459462 ) ;
460463
@@ -477,7 +480,7 @@ export class MongoBinaryDownload {
477480 . on ( 'error' , ( err : Error ) => {
478481 // log it without having debug enabled
479482 console . error ( `Couldnt download "${ downloadUrl } "!` , err . message ) ;
480- reject ( err ) ;
483+ reject ( new DownloadError ( downloadUrl , err . message ) ) ;
481484 } ) ;
482485 } ) ;
483486 }
0 commit comments