Skip to content

Commit

Permalink
use assert instead of new error
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrej-langr committed Dec 28, 2024
1 parent 608cb85 commit a454dd9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions packages/auth-provider-automerge-repo/src/AuthProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ export class AuthProvider extends EventEmitter<AuthProviderEvents> {
* 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,
Expand Down
4 changes: 1 addition & 3 deletions packages/auth/src/connection/getDeviceUserFromGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit a454dd9

Please sign in to comment.