Skip to content

Commit 10b8de0

Browse files
committed
chore: Improve type safety (#2627)
1 parent ab0361c commit 10b8de0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/lib/services/contest_task_pairs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Prisma } from '@prisma/client';
2+
13
import { default as db } from '$lib/server/database';
24

35
import type { ContestTaskPair, ContestTaskPairs } from '$lib/types/contest_task_pair';
@@ -58,7 +60,7 @@ export async function createContestTaskPair(
5860

5961
console.log('Created ContestTaskPair:', contestTaskPair);
6062
} catch (error) {
61-
if (error && typeof error === 'object' && 'code' in error && (error as any).code === 'P2002') {
63+
if (error instanceof Prisma.PrismaClientKnownRequestError && error.code === 'P2002') {
6264
console.log(`ContestTaskPair already exists: contestId=${contestId}, taskId=${taskId}`);
6365
return;
6466
}

0 commit comments

Comments
 (0)