@@ -158,11 +158,11 @@ async function _init() {
158158 }
159159 } catch ( error ) {
160160 logger . error ( 'could not initialize database' , { error} ) ;
161- throw new BedrockError (
162- 'Could not initialize database. ',
163- 'DatabaseError' , {
164- url : urls . sanitize ( config . url )
165- } , error ) ;
161+ throw new BedrockError ( 'Could not initialize database.' , {
162+ name : 'OperationError ',
163+ details : { url : urls . sanitize ( config . url ) } ,
164+ cause : error
165+ } ) ;
166166 }
167167}
168168
@@ -185,22 +185,21 @@ async function _initDatabase() {
185185 ' username=' + config . username +
186186 ' url=' + urls . sanitize ( config . url ) ) ;
187187 }
188- throw new BedrockError (
189- 'Could not initialize database. ',
190- 'DatabaseError' , {
191- url : urls . sanitize ( config . url ) ,
192- } , e ) ;
188+ throw new BedrockError ( 'Could not initialize database.' , {
189+ name : 'OperationError ',
190+ details : { url : urls . sanitize ( config . url ) } ,
191+ cause : e
192+ } ) ;
193193 }
194194 } finally {
195195 // force client to close connections (do not reuse connections used to init
196196 // database as other connections will be used later that may have different
197197 // credentials)
198198 if ( client ) {
199199 const force = true ;
200- client . close ( force ) . catch ( error => {
201- logger . error (
202- 'failed to close client used to initialize database' , { error} ) ;
203- } ) ;
200+ client . close ( force ) . catch (
201+ error => logger . error (
202+ 'failed to close client used to initialize database' , { error} ) ) ;
204203 }
205204 }
206205}
@@ -210,7 +209,7 @@ async function _dropCollections() {
210209 throw new BedrockError (
211210 'If bedrock.config.mongodb.dropCollection.onInit is specified, ' +
212211 'bedrock.config.mongodb.dropCollection.collections must also ' +
213- 'be specified.' , 'InvalidConfiguration' ) ;
212+ 'be specified.' , { name : 'DataError' } ) ;
214213 }
215214 // if collectionsToDrop array is empty, all collections should be dropped
216215 const cArray = bedrock . config . mongodb . dropCollections . collections ;
0 commit comments