Skip to content

Commit c2a7c1b

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

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

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

Lines changed: 2 additions & 6 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,
@@ -665,9 +663,7 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
665663

666664
const savedShares = unpack(serializedState) as SerializedState
667665

668-
if (!this.#user) {
669-
throw new Error('Cannot load state as user is missing on AuthProvider')
670-
}
666+
assert(this.#user, 'Cannot load state as user is missing on AuthProvider')
671667

672668
await Promise.all(
673669
Object.values(savedShares).map(async share => {

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)