From b9c0bb0d7e06baacaa0095a103e63a7053ac9c64 Mon Sep 17 00:00:00 2001 From: Iain Sproat <68657+iainsproat@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:52:16 +0000 Subject: [PATCH] fix(logging): remove duplicate log - the error is logged at the top level, so we do not need to log deeper - instead, wrap the error with the additional information and throw --- packages/server/db/migrations.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/server/db/migrations.ts b/packages/server/db/migrations.ts index bab6e69f19..d2af94d5aa 100644 --- a/packages/server/db/migrations.ts +++ b/packages/server/db/migrations.ts @@ -1,12 +1,15 @@ import { Knex } from 'knex' -import { logger } from '@/logging/logging' +import { DatabaseError } from '@/modules/shared/errors' +import { ensureError } from '@speckle/shared' export const migrateDbToLatest = async (params: { db: Knex; region: string }) => { const { db, region } = params try { await db.migrate.latest() } catch (err: unknown) { - logger.error({ err, region }, 'Error migrating db to latest for region "{region}".') - throw err + throw new DatabaseError('Error migrating db to latest for region "{region}".', { + cause: ensureError(err, 'Unknown postgres error'), + info: { region } + }) } }