From a7d312c763c33dbadc8a9abef193c010614133dc Mon Sep 17 00:00:00 2001 From: Krzysztof Jelski Date: Fri, 10 Jul 2020 15:36:53 +0200 Subject: [PATCH] Handle case with no accounts. Log error messages. (#3160) --- .../src/renderer/remote-electron-store.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/apps-electron/src/renderer/remote-electron-store.ts b/packages/apps-electron/src/renderer/remote-electron-store.ts index 879ecadac5..d0e9a9d2fb 100644 --- a/packages/apps-electron/src/renderer/remote-electron-store.ts +++ b/packages/apps-electron/src/renderer/remote-electron-store.ts @@ -14,28 +14,28 @@ export class RemoteElectronStore implements KeyringStore { all (cb: (key: string, value: KeyringJson) => void): void { this.#accountStore.all() - .then((result: { key: string, value: KeyringJson }[]) => result.forEach(({ key, value }) => cb(key, value))) - .catch(() => { - throw new Error('error getting all accounts'); + .then((result: { key: string, value: KeyringJson }[]) => result?.forEach(({ key, value }) => cb(key, value))) + .catch((e: Error) => { + throw new Error(`error getting all accounts: ${e.message}`); }); } get (key: string, cb: (value: KeyringJson) => void): void { this.#accountStore.get(key) - .then(cb).catch(() => { - throw new Error('error storing account'); + .then(cb).catch((e: Error) => { + throw new Error(`error storing account: ${e.message}`); }); } remove (key: string, cb: (() => void) | undefined): void { - this.#accountStore.remove(key).then(cb).catch(() => { - throw new Error('error removing account'); + this.#accountStore.remove(key).then(cb).catch((e: Error) => { + throw new Error(`error removing account: ${e.message}`); }); } set (key: string, value: KeyringJson, cb: (() => void) | undefined): void { - this.#accountStore.set(key, value).then(cb).catch(() => { - throw new Error('error saving account'); + this.#accountStore.set(key, value).then(cb).catch((e: Error) => { + throw new Error(`error saving account: ${e.message}`); }); } }