Use instanceof for database error handling
This commit is contained in:
parent
0bbfc4cdc3
commit
72135b22be
@ -70,19 +70,26 @@ export function DatabaseProvider({ children }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function handleDatabaseError(event) {
|
function handleDatabaseError(event) {
|
||||||
event.preventDefault();
|
if (event) {
|
||||||
if (event?.reason?.message?.startsWith("QuotaExceededError")) {
|
event.preventDefault();
|
||||||
setDatabaseError({
|
if (event.reason instanceof Dexie.QuotaExceededError) {
|
||||||
name: event?.reason?.name,
|
setDatabaseError({
|
||||||
message: "Storage Quota Exceeded Please Clear Space and Try Again.",
|
name: event.reason?.name,
|
||||||
});
|
message: "Storage Quota Exceeded Please Clear Space and Try Again.",
|
||||||
} else {
|
});
|
||||||
setDatabaseError({
|
} else if (event.reason instanceof Dexie.DatabaseClosedError) {
|
||||||
name: event?.reason?.name,
|
setDatabaseError({
|
||||||
message: "Something went wrong, please refresh your browser.",
|
name: event.reason?.name,
|
||||||
});
|
message: "Database closed, please refresh your browser.",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setDatabaseError({
|
||||||
|
name: event.reason?.name,
|
||||||
|
message: "Something went wrong, please refresh your browser.",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.error(event.reason);
|
||||||
}
|
}
|
||||||
console.error(event?.reason);
|
|
||||||
}
|
}
|
||||||
window.addEventListener("unhandledrejection", handleDatabaseError);
|
window.addEventListener("unhandledrejection", handleDatabaseError);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user