From 7994e8a7fc7a1e65877adb3a47fb109b3b9b9175 Mon Sep 17 00:00:00 2001 From: Justin Baur <19896123+justindbaur@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:10:28 -0500 Subject: [PATCH] Handle Unix Not Found Error --- .../main/desktop-credential-storage-listener.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/platform/main/desktop-credential-storage-listener.ts b/apps/desktop/src/platform/main/desktop-credential-storage-listener.ts index ca4d9a2d3ca..5402eb44d96 100644 --- a/apps/desktop/src/platform/main/desktop-credential-storage-listener.ts +++ b/apps/desktop/src/platform/main/desktop-credential-storage-listener.ts @@ -5,6 +5,10 @@ import { ipcMain } from "electron"; import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service"; import { passwords } from "@bitwarden/desktop-napi"; +const WindowsNotFoundError = "Password not found."; +const MacOSNotFoundError = "The specified item could not be found in the keychain."; +const UnixNotFoundError = "no result"; + export class DesktopCredentialStorageListener { constructor( private serviceName: string, @@ -36,12 +40,16 @@ export class DesktopCredentialStorageListener { return val; } catch (e) { if ( - e.message === "Password not found." || - e.message === "The specified item could not be found in the keychain." + e.message === WindowsNotFoundError || + e.message === MacOSNotFoundError || + e.message === UnixNotFoundError ) { return null; } - this.logService.info(e); + this.logService.warning( + `Error while event in the keytar action: ${message?.action ?? "Unknown action"}`, + e, + ); } }); }