try catch wrap

This commit is contained in:
Nate Kelley 2025-08-07 15:09:49 -06:00
parent b4b04188cf
commit 358e74149a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 20 additions and 13 deletions

View File

@ -11,23 +11,30 @@ export async function getReportHandler(
): Promise<GetReportIndividualResponse> {
const report = await getReport({ reportId, userId: user.id });
const platejsResult = await markdownToPlatejs(report.content);
try {
const platejsResult = await markdownToPlatejs(report.content);
if (platejsResult.error) {
console.error('Error converting markdown to PlateJS:', platejsResult.error);
if (platejsResult.error) {
console.error('Error converting markdown to PlateJS:', platejsResult.error);
throw new HTTPException(500, {
message: 'Error converting markdown to PlateJS',
});
}
const content = platejsResult.elements ?? [];
const response: GetReportIndividualResponse = {
...report,
content,
};
return response;
} catch (error) {
console.error('Error converting markdown to PlateJS:', error);
throw new HTTPException(500, {
message: 'Error converting markdown to PlateJS',
message: 'Error converting markdown',
});
}
const content = platejsResult.elements ?? [];
const response: GetReportIndividualResponse = {
...report,
content,
};
return response;
}
const app = new Hono()