@@ -162,11 +162,18 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
162162 engineGroup ,
163163 ) ;
164164
165- await this . sdk . collection . create (
166- engineId ,
167- InternalCollection . ASSETS ,
168- mappings ,
169- ) ;
165+ try {
166+ await this . sdk . collection . create (
167+ engineId ,
168+ InternalCollection . ASSETS ,
169+ mappings ,
170+ ) ;
171+ } catch ( error ) {
172+ throw new InternalError (
173+ `Failed to create the assets collection "${ InternalCollection . ASSETS } " for engine "${ engineId } ": ${ error . message } ` ,
174+ error ,
175+ ) ;
176+ }
170177
171178 return InternalCollection . ASSETS ;
172179 }
@@ -182,21 +189,35 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
182189
183190 _ . merge ( mappings . properties . asset , assetsCollectionMappings ) ;
184191
185- await this . sdk . collection . create (
186- engineId ,
187- InternalCollection . ASSETS_HISTORY ,
188- mappings ,
189- ) ;
192+ try {
193+ await this . sdk . collection . create (
194+ engineId ,
195+ InternalCollection . ASSETS_HISTORY ,
196+ mappings ,
197+ ) ;
198+ } catch ( error ) {
199+ throw new InternalError (
200+ `Failed to create the assets history collection "${ InternalCollection . ASSETS_HISTORY } " for engine "${ engineId } ": ${ error . message } ` ,
201+ error ,
202+ ) ;
203+ }
190204
191205 return InternalCollection . ASSETS_HISTORY ;
192206 }
193207
194208 async createAssetsGroupsCollection ( engineId : string ) {
195- await this . sdk . collection . create (
196- engineId ,
197- InternalCollection . ASSETS_GROUPS ,
198- { mappings : assetGroupsMappings } ,
199- ) ;
209+ try {
210+ await this . sdk . collection . create (
211+ engineId ,
212+ InternalCollection . ASSETS_GROUPS ,
213+ { mappings : assetGroupsMappings } ,
214+ ) ;
215+ } catch ( error ) {
216+ throw new InternalError (
217+ `Failed to create the assets groups collection "${ InternalCollection . ASSETS_GROUPS } " for engine "${ engineId } ": ${ error . message } ` ,
218+ error ,
219+ ) ;
220+ }
200221
201222 return InternalCollection . ASSETS_GROUPS ;
202223 }
@@ -260,23 +281,37 @@ export class DeviceManagerEngine extends AbstractEngine<DeviceManagerPlugin> {
260281 const mappings =
261282 await this . getDigitalTwinMappings < DeviceModelContent > ( "device" ) ;
262283
263- await this . sdk . collection . create (
264- engineId ,
265- InternalCollection . DEVICES ,
266- mappings ,
267- ) ;
284+ try {
285+ await this . sdk . collection . create (
286+ engineId ,
287+ InternalCollection . DEVICES ,
288+ mappings ,
289+ ) ;
290+ } catch ( error ) {
291+ throw new InternalError (
292+ `Failed to create the devices collection "${ InternalCollection . DEVICES } " for engine "${ engineId } ": ${ error . message } ` ,
293+ error ,
294+ ) ;
295+ }
268296
269297 return InternalCollection . DEVICES ;
270298 }
271299
272300 async createMeasuresCollection ( engineId : string , engineGroup : string ) {
273301 const mappings = await this . getMeasuresMappings ( engineGroup ) ;
274302
275- await this . sdk . collection . create (
276- engineId ,
277- InternalCollection . MEASURES ,
278- mappings ,
279- ) ;
303+ try {
304+ await this . sdk . collection . create (
305+ engineId ,
306+ InternalCollection . MEASURES ,
307+ mappings ,
308+ ) ;
309+ } catch ( error ) {
310+ throw new InternalError (
311+ `Failed to create the measures collection "${ InternalCollection . MEASURES } " for engine "${ engineId } ": ${ error . message } ` ,
312+ error ,
313+ ) ;
314+ }
280315
281316 return InternalCollection . MEASURES ;
282317 }
0 commit comments