From 5cb87a0fd99fa7684f474719bd5d7eec7a551387 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Oct 2023 16:24:10 -0500 Subject: [PATCH] db/events: fix catching UNIQUE violations --- src/db/events.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/db/events.ts b/src/db/events.ts index 6dade28..5749d94 100644 --- a/src/db/events.ts +++ b/src/db/events.ts @@ -1,5 +1,5 @@ import { db } from '@/db.ts'; -import { type Event, SqliteError } from '@/deps.ts'; +import { type Event } from '@/deps.ts'; import { isParameterizedReplaceableKind } from '@/kinds.ts'; import { jsonMetaContentSchema } from '@/schemas/nostr.ts'; import { EventData } from '@/types.ts'; @@ -64,7 +64,7 @@ function insertEvent(event: Event, data: EventData): Promise { ]); }).catch((error) => { // Don't throw for duplicate events. - if (error instanceof SqliteError && error.code === 19) { + if (error.message.includes('UNIQUE constraint failed')) { return; } else { throw error;