Fix database error not showing the right message

This commit is contained in:
Mitchell McCaffrey 2021-06-28 08:24:48 +10:00
parent cd826595cd
commit b7793626cf

View File

@ -72,16 +72,24 @@ export function DatabaseProvider({ children }) {
function handleDatabaseError(event) { function handleDatabaseError(event) {
if (event) { if (event) {
event.preventDefault(); event.preventDefault();
if (event.reason instanceof Dexie.QuotaExceededError) { if (event.reason instanceof Dexie.DexieError) {
setDatabaseError({ if (event.reason?.inner?.name === "QuotaExceededError") {
name: event.reason?.name, setDatabaseError({
message: "Storage Quota Exceeded Please Clear Space and Try Again.", name: event.reason?.name,
}); message:
} else if (event.reason instanceof Dexie.DatabaseClosedError) { "Storage Quota Exceeded Please Clear Space and Try Again.",
setDatabaseError({ });
name: event.reason?.name, } else if (event.reason?.inner?.name === "DatabaseClosedError") {
message: "Database closed, please refresh your browser.", setDatabaseError({
}); 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.",
});
}
} else { } else {
setDatabaseError({ setDatabaseError({
name: event.reason?.name, name: event.reason?.name,