9
9
AssetAdministrationShellRepositoryAPIApi as AasRepository ,
10
10
Configuration ,
11
11
PagedResultPagingMetadata ,
12
- RequiredError ,
12
+ Result ,
13
13
} from '../generated' ;
14
14
import { applyDefaults } from '../lib/apiConfig' ;
15
15
import { base64Encode } from '../lib/base64Url' ;
@@ -21,6 +21,7 @@ import {
21
21
convertCoreAssetInformationToApiAssetInformation ,
22
22
convertCoreReferenceToApiReference ,
23
23
} from '../lib/convertAasTypes' ;
24
+ import { handleApiError } from '../lib/errorHandler' ;
24
25
25
26
export class AasRepositoryClient {
26
27
/**
@@ -47,7 +48,7 @@ export class AasRepositoryClient {
47
48
pagedResult : PagedResultPagingMetadata | undefined ;
48
49
result : AssetAdministrationShell [ ] ;
49
50
} ,
50
- RequiredError
51
+ Result
51
52
>
52
53
> {
53
54
const { configuration, assetIds, idShort, limit, cursor } = options ;
@@ -69,7 +70,8 @@ export class AasRepositoryClient {
69
70
data : { pagedResult : result . pagingMetadata , result : shells } ,
70
71
} ;
71
72
} catch ( err ) {
72
- return { success : false , error : err as RequiredError } ;
73
+ const customError = await handleApiError ( err ) ;
74
+ return { success : false , error : customError } ;
73
75
}
74
76
}
75
77
@@ -85,7 +87,7 @@ export class AasRepositoryClient {
85
87
async postAssetAdministrationShell ( options : {
86
88
configuration : Configuration ;
87
89
assetAdministrationShell : AssetAdministrationShell ;
88
- } ) : Promise < ApiResult < AssetAdministrationShell , RequiredError > > {
90
+ } ) : Promise < ApiResult < AssetAdministrationShell , Result > > {
89
91
const { configuration, assetAdministrationShell } = options ;
90
92
91
93
try {
@@ -97,7 +99,8 @@ export class AasRepositoryClient {
97
99
98
100
return { success : true , data : convertApiAasToCoreAas ( result ) } ;
99
101
} catch ( err ) {
100
- return { success : false , error : err as RequiredError } ;
102
+ const customError = await handleApiError ( err ) ;
103
+ return { success : false , error : customError } ;
101
104
}
102
105
}
103
106
@@ -113,7 +116,7 @@ export class AasRepositoryClient {
113
116
async deleteAssetAdministrationShellById ( options : {
114
117
configuration : Configuration ;
115
118
aasIdentifier : string ;
116
- } ) : Promise < ApiResult < void , RequiredError > > {
119
+ } ) : Promise < ApiResult < void , Result > > {
117
120
const { configuration, aasIdentifier } = options ;
118
121
119
122
try {
@@ -127,7 +130,8 @@ export class AasRepositoryClient {
127
130
128
131
return { success : true , data : result } ;
129
132
} catch ( err ) {
130
- return { success : false , error : err as RequiredError } ;
133
+ const customError = await handleApiError ( err ) ;
134
+ return { success : false , error : customError } ;
131
135
}
132
136
}
133
137
@@ -143,7 +147,7 @@ export class AasRepositoryClient {
143
147
async getAssetAdministrationShellById ( options : {
144
148
configuration : Configuration ;
145
149
aasIdentifier : string ;
146
- } ) : Promise < ApiResult < AssetAdministrationShell , RequiredError > > {
150
+ } ) : Promise < ApiResult < AssetAdministrationShell , Result > > {
147
151
const { configuration, aasIdentifier } = options ;
148
152
149
153
try {
@@ -157,7 +161,8 @@ export class AasRepositoryClient {
157
161
158
162
return { success : true , data : convertApiAasToCoreAas ( result ) } ;
159
163
} catch ( err ) {
160
- return { success : false , error : err as RequiredError } ;
164
+ const customError = await handleApiError ( err ) ;
165
+ return { success : false , error : customError } ;
161
166
}
162
167
}
163
168
@@ -175,7 +180,7 @@ export class AasRepositoryClient {
175
180
configuration : Configuration ;
176
181
aasIdentifier : string ;
177
182
assetAdministrationShell : AssetAdministrationShell ;
178
- } ) : Promise < ApiResult < void , RequiredError > > {
183
+ } ) : Promise < ApiResult < void , Result > > {
179
184
const { configuration, aasIdentifier, assetAdministrationShell } = options ;
180
185
181
186
try {
@@ -190,7 +195,8 @@ export class AasRepositoryClient {
190
195
191
196
return { success : true , data : result } ;
192
197
} catch ( err ) {
193
- return { success : false , error : err as RequiredError } ;
198
+ const customError = await handleApiError ( err ) ;
199
+ return { success : false , error : customError } ;
194
200
}
195
201
}
196
202
@@ -206,7 +212,7 @@ export class AasRepositoryClient {
206
212
async getAssetInformation ( options : {
207
213
configuration : Configuration ;
208
214
aasIdentifier : string ;
209
- } ) : Promise < ApiResult < AssetInformation , RequiredError > > {
215
+ } ) : Promise < ApiResult < AssetInformation , Result > > {
210
216
const { configuration, aasIdentifier } = options ;
211
217
212
218
try {
@@ -223,7 +229,8 @@ export class AasRepositoryClient {
223
229
data : convertApiAssetInformationToCoreAssetInformation ( result ) ,
224
230
} ;
225
231
} catch ( err ) {
226
- return { success : false , error : err as RequiredError } ;
232
+ const customError = await handleApiError ( err ) ;
233
+ return { success : false , error : customError } ;
227
234
}
228
235
}
229
236
@@ -241,7 +248,7 @@ export class AasRepositoryClient {
241
248
configuration : Configuration ;
242
249
aasIdentifier : string ;
243
250
assetInformation : AssetInformation ;
244
- } ) : Promise < ApiResult < void , RequiredError > > {
251
+ } ) : Promise < ApiResult < void , Result > > {
245
252
const { configuration, aasIdentifier, assetInformation } = options ;
246
253
247
254
try {
@@ -256,7 +263,8 @@ export class AasRepositoryClient {
256
263
257
264
return { success : true , data : result } ;
258
265
} catch ( err ) {
259
- return { success : false , error : err as RequiredError } ;
266
+ const customError = await handleApiError ( err ) ;
267
+ return { success : false , error : customError } ;
260
268
}
261
269
}
262
270
@@ -272,7 +280,7 @@ export class AasRepositoryClient {
272
280
async deleteThumbnail ( options : {
273
281
configuration : Configuration ;
274
282
aasIdentifier : string ;
275
- } ) : Promise < ApiResult < void , RequiredError > > {
283
+ } ) : Promise < ApiResult < void , Result > > {
276
284
const { configuration, aasIdentifier } = options ;
277
285
try {
278
286
const apiInstance = new AasRepository ( applyDefaults ( configuration ) ) ;
@@ -285,7 +293,8 @@ export class AasRepositoryClient {
285
293
286
294
return { success : true , data : result } ;
287
295
} catch ( err ) {
288
- return { success : false , error : err as RequiredError } ;
296
+ const customError = await handleApiError ( err ) ;
297
+ return { success : false , error : customError } ;
289
298
}
290
299
}
291
300
@@ -301,7 +310,7 @@ export class AasRepositoryClient {
301
310
async getThumbnail ( options : {
302
311
configuration : Configuration ;
303
312
aasIdentifier : string ;
304
- } ) : Promise < ApiResult < Blob , RequiredError > > {
313
+ } ) : Promise < ApiResult < Blob , Result > > {
305
314
const { configuration, aasIdentifier } = options ;
306
315
307
316
try {
@@ -315,7 +324,8 @@ export class AasRepositoryClient {
315
324
316
325
return { success : true , data : result } ;
317
326
} catch ( err ) {
318
- return { success : false , error : err as RequiredError } ;
327
+ const customError = await handleApiError ( err ) ;
328
+ return { success : false , error : customError } ;
319
329
}
320
330
}
321
331
@@ -335,7 +345,7 @@ export class AasRepositoryClient {
335
345
aasIdentifier : string ;
336
346
fileName : string ;
337
347
file : Blob ;
338
- } ) : Promise < ApiResult < void , RequiredError > > {
348
+ } ) : Promise < ApiResult < void , Result > > {
339
349
const { configuration, aasIdentifier, fileName, file } = options ;
340
350
341
351
try {
@@ -351,7 +361,8 @@ export class AasRepositoryClient {
351
361
352
362
return { success : true , data : result } ;
353
363
} catch ( err ) {
354
- return { success : false , error : err as RequiredError } ;
364
+ const customError = await handleApiError ( err ) ;
365
+ return { success : false , error : customError } ;
355
366
}
356
367
}
357
368
@@ -371,7 +382,7 @@ export class AasRepositoryClient {
371
382
aasIdentifier : string ;
372
383
limit ?: number ;
373
384
cursor ?: string ;
374
- } ) : Promise < ApiResult < { pagedResult : PagedResultPagingMetadata | undefined ; result : Reference [ ] } , RequiredError > > {
385
+ } ) : Promise < ApiResult < { pagedResult : PagedResultPagingMetadata | undefined ; result : Reference [ ] } , Result > > {
375
386
const { configuration, aasIdentifier, limit, cursor } = options ;
376
387
377
388
try {
@@ -394,7 +405,8 @@ export class AasRepositoryClient {
394
405
} ,
395
406
} ;
396
407
} catch ( err ) {
397
- return { success : false , error : err as RequiredError } ;
408
+ const customError = await handleApiError ( err ) ;
409
+ return { success : false , error : customError } ;
398
410
}
399
411
}
400
412
@@ -412,7 +424,7 @@ export class AasRepositoryClient {
412
424
configuration : Configuration ;
413
425
aasIdentifier : string ;
414
426
submodelReference : Reference ;
415
- } ) : Promise < ApiResult < Reference , RequiredError > > {
427
+ } ) : Promise < ApiResult < Reference , Result > > {
416
428
const { configuration, aasIdentifier, submodelReference } = options ;
417
429
418
430
try {
@@ -427,7 +439,8 @@ export class AasRepositoryClient {
427
439
428
440
return { success : true , data : convertApiReferenceToCoreReference ( result ) } ;
429
441
} catch ( err ) {
430
- return { success : false , error : err as RequiredError } ;
442
+ const customError = await handleApiError ( err ) ;
443
+ return { success : false , error : customError } ;
431
444
}
432
445
}
433
446
@@ -445,7 +458,7 @@ export class AasRepositoryClient {
445
458
configuration : Configuration ;
446
459
aasIdentifier : string ;
447
460
submodelIdentifier : string ;
448
- } ) : Promise < ApiResult < void , RequiredError > > {
461
+ } ) : Promise < ApiResult < void , Result > > {
449
462
const { configuration, aasIdentifier, submodelIdentifier } = options ;
450
463
451
464
try {
@@ -461,7 +474,8 @@ export class AasRepositoryClient {
461
474
462
475
return { success : true , data : result } ;
463
476
} catch ( err ) {
464
- return { success : false , error : err as RequiredError } ;
477
+ const customError = await handleApiError ( err ) ;
478
+ return { success : false , error : customError } ;
465
479
}
466
480
}
467
481
}
0 commit comments