blob: 4b101f898245c0e3ecbd972717de32e62b3fc65d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
/**
* True when the failure is SQLite's UNIQUE constraint. Drizzle wraps driver
* errors, so the libsql error sits at some depth of the `cause` chain.
*/
export function isUniqueViolation(error: unknown): boolean {
let current: unknown = error;
while (current instanceof Error) {
if ('code' in current && current.code === 'SQLITE_CONSTRAINT_UNIQUE')
return true;
current = current.cause;
}
return false;
}
|