Skip to content

Commit a454dd9

Browse files
committed
use assert instead of new error
1 parent 608cb85 commit a454dd9

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

packages/auth-provider-automerge-repo/src/AuthProvider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
211211
* Creates a team and registers it with all of our sync servers.
212212
*/
213213
public async createTeam(teamName: string) {
214-
if (!this.#user) {
215-
throw new Error('Cannot create team as user is missing on AuthProvider')
216-
}
214+
assert(this.#user, 'Cannot create team as user is missing on AuthProvider')
217215

218216
const team = Auth.createTeam(teamName, {
219217
device: this.#device,

packages/auth/src/connection/getDeviceUserFromGraph.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@ export const getDeviceUserFromGraph = ({
4343
const userKeyring = select.keyring(state, { type: USER, name: userId }, starterKeys)
4444
const keys = getLatestGeneration(userKeyring)
4545

46-
if (!keys) {
47-
throw new Error('Failed to get device user from graph as there are no keys for user keyring')
48-
}
46+
assert(keys, 'Failed to get device user from graph as there are no keys for user keyring')
4947

5048
const user: UserWithSecrets = { userName, userId, keys }
5149

0 commit comments

Comments
 (0)