Debug: add try/catch and JSON sanitize in saveLesson
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,15 +22,20 @@ export async function saveLesson(
|
||||
}
|
||||
) {
|
||||
await requireAdmin();
|
||||
await prisma.lesson.update({
|
||||
where: { id: lessonId },
|
||||
data: {
|
||||
title: data.title,
|
||||
kinescopeId: data.kinescopeId || null,
|
||||
content: data.content,
|
||||
published: data.published,
|
||||
},
|
||||
});
|
||||
try {
|
||||
await prisma.lesson.update({
|
||||
where: { id: lessonId },
|
||||
data: {
|
||||
title: data.title,
|
||||
kinescopeId: data.kinescopeId || null,
|
||||
content: JSON.parse(JSON.stringify(data.content)),
|
||||
published: data.published,
|
||||
},
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("[saveLesson] full error:", err);
|
||||
throw err;
|
||||
}
|
||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}`);
|
||||
revalidatePath(`/admin/courses/${courseId}/modules/${moduleId}/lessons/${lessonId}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user