fix: add suuport Japanese message of errors. (#11159)

* fix: add suuport Japanese message of errors.

* fix: change catching function.

* lint

---------

Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
This commit is contained in:
SASAGAWA Kiyoshi 2023-07-08 21:10:52 +09:00 committed by GitHub
parent d2764944cf
commit 246d167c81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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';
}