From e722866d62da2aec9ce00ad81f50ec4bbcd2c39c Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 13 May 2024 09:55:06 +0500 Subject: [PATCH] web: better handling of `database disk image is malformed` error --- apps/web/src/components/error-boundary/index.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/error-boundary/index.tsx b/apps/web/src/components/error-boundary/index.tsx index bd3aa3121..ad0cd7934 100644 --- a/apps/web/src/components/error-boundary/index.tsx +++ b/apps/web/src/components/error-boundary/index.tsx @@ -162,9 +162,9 @@ function getErrorHelp(props: FallbackProps) { if ( errorText.includes("file is not a database") || errorText.includes("unsupported file format") || - errorText.includes("database disk image is malformed") || errorText.includes("null function or function signature mismatch") || - errorText.includes("malformed database schema") + errorText.includes("malformed database schema") || + /table ".+?" already exists/.test(errorText) ) { return { explanation: `This error usually means the database file is either corrupt or it could not be decrypted.`, @@ -195,6 +195,17 @@ function getErrorHelp(props: FallbackProps) { resetErrorBoundary(); } }; + } else if (errorText.includes("database disk image is malformed")) { + return { + explanation: `This error usually means the search index is corrupted.`, + action: + "This error can be fixed by rebuilding the search index. This action won't result in any kind of data loss.", + fix: async () => { + const { db } = await import("../../common/db"); + await db.lookup.rebuild(); + resetErrorBoundary(); + } + }; } }