Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit de9190b

Browse files
committed
Remove exception swallowing
This seems like it causes more problems than it solves.
1 parent 2cff520 commit de9190b

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

src/utils/device/isDeviceVerified.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,10 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
2626
* indicating whether the device has been cross-signed by a cross-signing key we trust.
2727
*/
2828
export const isDeviceVerified = async (client: MatrixClient, deviceId: string): Promise<boolean | null> => {
29-
try {
30-
const trustLevel = await client.getCrypto()?.getDeviceVerificationStatus(client.getSafeUserId(), deviceId);
31-
if (!trustLevel) {
32-
// either no crypto, or an unknown/no-e2e device
33-
return null;
34-
}
35-
return trustLevel.crossSigningVerified;
36-
} catch (e) {
37-
console.error("Error getting device cross-signing info", e);
29+
const trustLevel = await client.getCrypto()?.getDeviceVerificationStatus(client.getSafeUserId(), deviceId);
30+
if (!trustLevel) {
31+
// either no crypto, or an unknown/no-e2e device
3832
return null;
3933
}
34+
return trustLevel.crossSigningVerified;
4035
};

test/components/views/settings/tabs/user/SessionManagerTab-test.tsx

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -227,27 +227,6 @@ describe("<SessionManagerTab />", () => {
227227
expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy();
228228
});
229229

230-
it("does not fail when checking device verification fails", async () => {
231-
const logSpy = jest.spyOn(console, "error").mockImplementation((e) => {});
232-
mockClient.getDevices.mockResolvedValue({
233-
devices: [alicesDevice, alicesMobileDevice],
234-
});
235-
const failError = new Error("non-specific failure");
236-
mockCrypto.getDeviceVerificationStatus.mockImplementation(() => {
237-
throw failError;
238-
});
239-
render(getComponent());
240-
241-
await act(async () => {
242-
await flushPromises();
243-
});
244-
245-
// called for each device despite error
246-
expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesDevice.device_id);
247-
expect(mockCrypto.getDeviceVerificationStatus).toHaveBeenCalledWith(aliceId, alicesMobileDevice.device_id);
248-
expect(logSpy).toHaveBeenCalledWith("Error getting device cross-signing info", failError);
249-
});
250-
251230
it("sets device verification status correctly", async () => {
252231
mockClient.getDevices.mockResolvedValue({
253232
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],

0 commit comments

Comments
 (0)