@@ -287,6 +287,18 @@ export class ReportsService {
287
287
throw new InternalServerErrorException (
288
288
`Table "${ this . tableName } " not found. Please check your database configuration.` ,
289
289
) ;
290
+ } else if ( error . name === 'ValidationException' ) {
291
+ this . logger . error (
292
+ `DynamoDB validation error updating status for report ID ${ id } : ${ error . message } ` ,
293
+ ) ;
294
+ throw new InternalServerErrorException (
295
+ `Validation error updating report status: ${ error . message } ` ,
296
+ ) ;
297
+ } else if ( error . name === 'ProvisionedThroughputExceededException' ) {
298
+ this . logger . warn ( `DynamoDB throughput exceeded for report ID ${ id } ` ) ;
299
+ throw new InternalServerErrorException (
300
+ 'Database capacity limit reached, please try again later' ,
301
+ ) ;
290
302
}
291
303
}
292
304
@@ -390,10 +402,21 @@ export class ReportsService {
390
402
id : report . id , // Sort key
391
403
} ) ,
392
404
UpdateExpression :
393
- 'SET title = :title, bookmarked = :bookmarked, category = :category, ' +
394
- 'processingStatus = :processingStatus, labValues = :labValues, summary = :summary, ' +
395
- 'confidence = :confidence, status = :status, updatedAt = :updatedAt' ,
405
+ 'SET # title = :title, # bookmarked = :bookmarked, # category = :category, ' +
406
+ '# processingStatus = :processingStatus, # labValues = :labValues, # summary = :summary, ' +
407
+ '# confidence = :confidence, # status = :status, # updatedAt = :updatedAt' ,
396
408
ConditionExpression : 'userId = :userId' , // Ensure the report belongs to the user
409
+ ExpressionAttributeNames : {
410
+ '#title' : 'title' ,
411
+ '#bookmarked' : 'bookmarked' ,
412
+ '#category' : 'category' ,
413
+ '#processingStatus' : 'processingStatus' ,
414
+ '#labValues' : 'labValues' ,
415
+ '#summary' : 'summary' ,
416
+ '#confidence' : 'confidence' ,
417
+ '#status' : 'status' ,
418
+ '#updatedAt' : 'updatedAt' ,
419
+ } ,
397
420
ExpressionAttributeValues : marshall ( {
398
421
':title' : report . title ,
399
422
':bookmarked' : report . bookmarked ,
@@ -431,6 +454,18 @@ export class ReportsService {
431
454
throw new InternalServerErrorException (
432
455
`Table "${ this . tableName } " not found. Please check your database configuration.` ,
433
456
) ;
457
+ } else if ( error . name === 'ValidationException' ) {
458
+ this . logger . error (
459
+ `DynamoDB validation error for report ID ${ report . id } : ${ error . message } ` ,
460
+ ) ;
461
+ throw new InternalServerErrorException (
462
+ `Validation error updating report: ${ error . message } ` ,
463
+ ) ;
464
+ } else if ( error . name === 'ProvisionedThroughputExceededException' ) {
465
+ this . logger . warn ( `DynamoDB throughput exceeded for report ID ${ report . id } ` ) ;
466
+ throw new InternalServerErrorException (
467
+ 'Database capacity limit reached, please try again later' ,
468
+ ) ;
434
469
}
435
470
}
436
471
@@ -505,6 +540,18 @@ export class ReportsService {
505
540
throw new InternalServerErrorException (
506
541
`Table "${ this . tableName } " not found. Please check your database configuration.` ,
507
542
) ;
543
+ } else if ( error . name === 'ValidationException' ) {
544
+ this . logger . error (
545
+ `DynamoDB validation error toggling bookmark for report ID ${ id } : ${ error . message } ` ,
546
+ ) ;
547
+ throw new InternalServerErrorException (
548
+ `Validation error toggling bookmark: ${ error . message } ` ,
549
+ ) ;
550
+ } else if ( error . name === 'ProvisionedThroughputExceededException' ) {
551
+ this . logger . warn ( `DynamoDB throughput exceeded for report ID ${ id } ` ) ;
552
+ throw new InternalServerErrorException (
553
+ 'Database capacity limit reached, please try again later' ,
554
+ ) ;
508
555
}
509
556
}
510
557
0 commit comments