refactor: created custom error for a token already exists

This commit is contained in:
2024-06-16 08:47:07 -04:00
parent f9d7a6bbd2
commit 3b1fe66261
3 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import { eq, or, sql } from "drizzle-orm";
import { TokenAlreadyExistsError } from "~/libs/errors/TokenAlreadyExists";
import type { Env } from "~/types/env";
import { getDb } from "./db";
@@ -34,7 +35,7 @@ export function saveToken(
!existingToken.username &&
!username
) {
throw new Error("Token already exists in the database");
throw new TokenAlreadyExistsError();
}
return updateToken(env, deviceId, token, username);