From 246d167c81ef65001ec92e34f4878970a973f52f Mon Sep 17 00:00:00 2001 From: SASAGAWA Kiyoshi Date: Sat, 8 Jul 2023 21:10:52 +0900 Subject: [PATCH] fix: add suuport Japanese message of errors. (#11159) * fix: add suuport Japanese message of errors. * fix: change catching function. * lint --------- Co-authored-by: syuilo --- packages/backend/src/misc/is-duplicate-key-value-error.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/misc/is-duplicate-key-value-error.ts b/packages/backend/src/misc/is-duplicate-key-value-error.ts index 04ff191e4..f5343d187 100644 --- a/packages/backend/src/misc/is-duplicate-key-value-error.ts +++ b/packages/backend/src/misc/is-duplicate-key-value-error.ts @@ -1,3 +1,5 @@ +import { QueryFailedError } from 'typeorm'; + export function isDuplicateKeyValueError(e: unknown | Error): boolean { - return (e as any).message && (e as Error).message.startsWith('duplicate key value'); + return e instanceof QueryFailedError && e.driverError.code === '23505'; }