From a96193bbf804e8bb8dadfbfa9372cccbddc1b5a4 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sun, 10 Nov 2024 18:14:44 +0530 Subject: [PATCH] feat: Add error handling for updating message by index Adds error handling to the `updateMessageByIndex` function to prevent the temporary chat from breaking when an error occurs during the update process. This ensures a more robust and reliable experience for users. --- src/db/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/db/index.ts b/src/db/index.ts index e4c136c..da837b2 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -355,10 +355,14 @@ export const updateMessageByIndex = async ( index: number, message: string ) => { + try { const db = new PageAssitDatabase() const chatHistory = (await db.getChatHistory(history_id)).reverse() chatHistory[index].content = message await db.db.set({ [history_id]: chatHistory.reverse() }) + } catch(e) { + // temp chat will break + } } export const deleteChatForEdit = async (history_id: string, index: number) => {