Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 50 additions & 3 deletions backend/src/reports/reports.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,18 @@ export class ReportsService {
throw new InternalServerErrorException(
`Table "${this.tableName}" not found. Please check your database configuration.`,
);
} else if (error.name === 'ValidationException') {
this.logger.error(
`DynamoDB validation error updating status for report ID ${id}: ${error.message}`,
);
throw new InternalServerErrorException(
`Validation error updating report status: ${error.message}`,
);
} else if (error.name === 'ProvisionedThroughputExceededException') {
this.logger.warn(`DynamoDB throughput exceeded for report ID ${id}`);
throw new InternalServerErrorException(
'Database capacity limit reached, please try again later',
);
}
}

Expand Down Expand Up @@ -390,10 +402,21 @@ export class ReportsService {
id: report.id, // Sort key
}),
UpdateExpression:
'SET title = :title, bookmarked = :bookmarked, category = :category, ' +
'processingStatus = :processingStatus, labValues = :labValues, summary = :summary, ' +
'confidence = :confidence, status = :status, updatedAt = :updatedAt',
'SET #title = :title, #bookmarked = :bookmarked, #category = :category, ' +
'#processingStatus = :processingStatus, #labValues = :labValues, #summary = :summary, ' +
'#confidence = :confidence, #status = :status, #updatedAt = :updatedAt',
ConditionExpression: 'userId = :userId', // Ensure the report belongs to the user
ExpressionAttributeNames: {
'#title': 'title',
'#bookmarked': 'bookmarked',
'#category': 'category',
'#processingStatus': 'processingStatus',
'#labValues': 'labValues',
'#summary': 'summary',
'#confidence': 'confidence',
'#status': 'status',
'#updatedAt': 'updatedAt',
},
ExpressionAttributeValues: marshall({
':title': report.title,
':bookmarked': report.bookmarked,
Expand Down Expand Up @@ -431,6 +454,18 @@ export class ReportsService {
throw new InternalServerErrorException(
`Table "${this.tableName}" not found. Please check your database configuration.`,
);
} else if (error.name === 'ValidationException') {
this.logger.error(
`DynamoDB validation error for report ID ${report.id}: ${error.message}`,
);
throw new InternalServerErrorException(
`Validation error updating report: ${error.message}`,
);
} else if (error.name === 'ProvisionedThroughputExceededException') {
this.logger.warn(`DynamoDB throughput exceeded for report ID ${report.id}`);
throw new InternalServerErrorException(
'Database capacity limit reached, please try again later',
);
}
}

Expand Down Expand Up @@ -505,6 +540,18 @@ export class ReportsService {
throw new InternalServerErrorException(
`Table "${this.tableName}" not found. Please check your database configuration.`,
);
} else if (error.name === 'ValidationException') {
this.logger.error(
`DynamoDB validation error toggling bookmark for report ID ${id}: ${error.message}`,
);
throw new InternalServerErrorException(
`Validation error toggling bookmark: ${error.message}`,
);
} else if (error.name === 'ProvisionedThroughputExceededException') {
this.logger.warn(`DynamoDB throughput exceeded for report ID ${id}`);
throw new InternalServerErrorException(
'Database capacity limit reached, please try again later',
);
}
}

Expand Down