From bfd6d0ada13d55e1c947091cf02486babbca0fe3 Mon Sep 17 00:00:00 2001 From: Mark J Date: Fri, 9 May 2025 10:17:03 +0000 Subject: [PATCH] A fix for the e2e issue which restores the use of a catch block --- src/utils/identity.ts | 9 +++++++-- src/views/User/LoginView.vue | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/utils/identity.ts b/src/utils/identity.ts index 665e6d070..3b741793f 100644 --- a/src/utils/identity.ts +++ b/src/utils/identity.ts @@ -38,7 +38,8 @@ export async function changeIdentity(identity: IPerson): Promise { * the current identity used */ export async function initializeCurrentActor( - identities: IPerson[] | undefined + identities: IPerson[] | undefined, + rethrow = false ): Promise { const actorId = localStorage.getItem(AUTH_USER_ACTOR_ID); console.debug("Initializing current actor", actorId); @@ -62,6 +63,10 @@ export async function initializeCurrentActor( await changeIdentity(activeIdentity); } } catch (e) { - console.error("Failed to initialize current Actor", e); + if (rethrow) { + throw e; + } else { + console.error("Failed to initialize current Actor", e); + } } } diff --git a/src/views/User/LoginView.vue b/src/views/User/LoginView.vue index 72e12faad..146a7b8f3 100644 --- a/src/views/User/LoginView.vue +++ b/src/views/User/LoginView.vue @@ -239,7 +239,13 @@ const loginAction = async (e: Event) => { throw new Error("Loading user's identities failed"); } - await initializeCurrentActor(currentUserIdentitiesResult.loggedUser.actors); + // at some point this function was refactored to log errors rather than + // throwing them, which made the catch below useless. The second argument + // specifies that errors should be thrown instead of logged + await initializeCurrentActor( + currentUserIdentitiesResult.loggedUser.actors, + true + ); // Step 3a following const loggedUserLocationResult = await loggedUserLocationPromise;