Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper context to rethrow in PrivacyAsyncStorage #1018

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/Utility/PrivacyAsyncStorage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IDBPDatabase, openDB } from 'idb';
import type { SetOptional } from 'type-fest';
import { rethrow } from './errors';
import t from './i18n';

export type PrivacyAsyncStorageOption = {
/** Name of the database */
Expand Down Expand Up @@ -63,7 +64,14 @@ export class PrivacyAsyncStorage {
: (this.#options.version || 1) + 1;
return;
}
rethrow(e);
rethrow(
e,
'Unexpected error while opening IndexedDB in PrivacyAsyncStorage.getDb',
{
options: this.#options,
},
t('indexeddb-error', 'error-msg')
);
})
.then((db) => {
if (db && !db.objectStoreNames.contains(this.#options.storeName)) {
Expand Down Expand Up @@ -141,7 +149,7 @@ export class PrivacyAsyncStorage {
db?.close();
return;
}
rethrow(e);
rethrow(e, 'Error in doesStoreExist', { name, storeName, db }, t('indexeddb-error', 'error-msg'));
});

if (db) {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@
},
"error-msg": {
"company-not-found": "Das gewünschte Unternehmen wurde nicht gefunden.",
"sva-not-found": "Beim Laden der Informationen zu der Datenschutz-Aufsichtsbehörde ist ein Fehler aufgetreten."
"sva-not-found": "Beim Laden der Informationen zu der Datenschutz-Aufsichtsbehörde ist ein Fehler aufgetreten.",
"indexeddb-error": "Beim Zugreifen auf die Datenbank in Deinem Browser ist ein unerwarteter Fehler aufgetreten."
},
"suggest": {
"success": "Dein Vorschlag wurde erfolgreich abgesendet. Vielen Dank noch einmal! Wir werden ihn jetzt schnellstmöglich überprüfen.",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,8 @@
},
"error-msg": {
"company-not-found": "The company you were looking for could not be found.",
"sva-not-found": "Loading the data on the supervisory authority failed."
"sva-not-found": "Loading the data on the supervisory authority failed.",
"indexeddb-error": "An unexpected error occured while trying to access the database in your browser."
},
"suggest": {
"success": "Your contribution has been sent successfully. Thank you! We will now review it as soon as possible.",
Expand Down