mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 01:03:09 +02:00
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:
parent
d2764944cf
commit
246d167c81
1 changed files with 3 additions and 1 deletions
|
@ -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';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue