From de9190ba0410d8be04c1aa628cd73d0e3c532db1 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 24 May 2023 15:31:10 +0100 Subject: [PATCH] Remove exception swallowing This seems like it causes more problems than it solves. --- src/utils/device/isDeviceVerified.ts | 13 ++++-------- .../tabs/user/SessionManagerTab-test.tsx | 21 ------------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/utils/device/isDeviceVerified.ts b/src/utils/device/isDeviceVerified.ts index 3aabf264db1..a139069fe27 100644 --- a/src/utils/device/isDeviceVerified.ts +++ b/src/utils/device/isDeviceVerified.ts @@ -26,15 +26,10 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix"; * indicating whether the device has been cross-signed by a cross-signing key we trust. */ export const isDeviceVerified = async (client: MatrixClient, deviceId: string): Promise => { - try { - const trustLevel = await client.getCrypto()?.getDeviceVerificationStatus(client.getSafeUserId(), deviceId); - if (!trustLevel) { - // either no crypto, or an unknown/no-e2e device - return null; - } - return trustLevel.crossSigningVerified; - } catch (e) { - console.error("Error getting device cross-signing info", e); + const trustLevel = await client.getCrypto()?.getDeviceVerificationStatus(client.getSafeUserId(), deviceId); + if (!trustLevel) { + // either no crypto, or an unknown/no-e2e device return null; } + return trustLevel.crossSigningVerified; }; diff --git a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx index 0944f7e31eb..d2b0d4d430b 100644 --- a/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx +++ b/test/components/views/settings/tabs/user/SessionManagerTab-test.tsx @@ -227,27 +227,6 @@ describe("", () => { expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy(); }); - it("does not fail when checking device verification fails", async () => { - const logSpy = jest.spyOn(console, "error").mockImplementation((e) => {}); - mockClient.getDevices.mockResolvedValue({ - devices: [alicesDevice, alicesMobileDevice], - }); - const failError = new Error("non-specific failure"); - mockCrypto.getDeviceVerificationStatus.mockImplementation(() => { - throw failError; - }); - render(getComponent()); - - await act(async () => { - await flushPromises(); - }); - - // called for each device despite error - expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesDevice.device_id); - expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesMobileDevice.device_id); - expect(logSpy).toHaveBeenCalledWith("Error getting device cross-signing info", failError); - }); - it("sets device verification status correctly", async () => { mockClient.getDevices.mockResolvedValue({ devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],