Skip to content

Commit

Permalink
Add better guard
Browse files Browse the repository at this point in the history
  • Loading branch information
aeharding committed Jan 31, 2025
1 parent 1d526f4 commit ddfa86f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/listeners/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ if (isNative() && isAppleDeviceInstallable()) {
try {
await Dexie.exists("WefwefDB");
} catch (error) {
if (!(error instanceof Error)) throw error;
if (error.name !== "UnknownError") throw error;
if (
!error.message.includes(
"Connection to Indexed Database server lost. Refresh the page to try again",
)
)
throw error;

console.info("Failed database integrity check!", error);

localStorage.setItem(DB_CLOSED_STORAGE_KEY, Date.now().toString());
localStorage.setItem("ERRNAME", (error as Error).name);
localStorage.setItem("ERRMESSAGE", (error as Error).message);

window.location.reload();

Expand Down

0 comments on commit ddfa86f

Please sign in to comment.