fix: 🐛 proper isDuplicateKeyValueError handling

Closes #10340
Co-authored-by: Kainoa Kanter <kainoa@t1c.dev>
This commit is contained in:
naskya 2023-06-22 16:25:27 -07:00 committed by ThatOneCalculator
parent a0a4423f45
commit d5854c2324
No known key found for this signature in database
GPG key ID: 8703CACD01000000

View file

@ -1,3 +1,4 @@
export function isDuplicateKeyValueError(e: unknown | Error): boolean {
return (e as Error).message?.startsWith("duplicate key value");
const nodeError = e as NodeJS.ErrnoException;
return nodeError.code === "23505";
}