From a454dd97bb2bbf663aedf1125951e3268ab60e26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ondr=CC=8Cej=20Langr?= Date: Sat, 28 Dec 2024 20:28:12 +0100 Subject: [PATCH] use assert instead of new error --- packages/auth-provider-automerge-repo/src/AuthProvider.ts | 4 +--- packages/auth/src/connection/getDeviceUserFromGraph.ts | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/auth-provider-automerge-repo/src/AuthProvider.ts b/packages/auth-provider-automerge-repo/src/AuthProvider.ts index 188cfc1a..2036403c 100644 --- a/packages/auth-provider-automerge-repo/src/AuthProvider.ts +++ b/packages/auth-provider-automerge-repo/src/AuthProvider.ts @@ -211,9 +211,7 @@ export class AuthProvider extends EventEmitter { * Creates a team and registers it with all of our sync servers. */ public async createTeam(teamName: string) { - if (!this.#user) { - throw new Error('Cannot create team as user is missing on AuthProvider') - } + assert(this.#user, 'Cannot create team as user is missing on AuthProvider') const team = Auth.createTeam(teamName, { device: this.#device, diff --git a/packages/auth/src/connection/getDeviceUserFromGraph.ts b/packages/auth/src/connection/getDeviceUserFromGraph.ts index 7dbf1267..4b6dfcf0 100644 --- a/packages/auth/src/connection/getDeviceUserFromGraph.ts +++ b/packages/auth/src/connection/getDeviceUserFromGraph.ts @@ -43,9 +43,7 @@ export const getDeviceUserFromGraph = ({ const userKeyring = select.keyring(state, { type: USER, name: userId }, starterKeys) const keys = getLatestGeneration(userKeyring) - if (!keys) { - throw new Error('Failed to get device user from graph as there are no keys for user keyring') - } + assert(keys, 'Failed to get device user from graph as there are no keys for user keyring') const user: UserWithSecrets = { userName, userId, keys }