Skip to content

Commit f9f2b9d

Browse files
committed
fix error handling
1 parent 053a3ca commit f9f2b9d

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/drizzle/src/upsertRow/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,15 @@ export const upsertRow = async <T extends Record<string, unknown> | TypeWithID>(
379379
// //////////////////////////////////
380380
// Error Handling
381381
// //////////////////////////////////
382-
} catch (error) {
382+
} catch (catchedError) {
383383
// Unique constraint violation error
384384
// '23505' is the code for PostgreSQL, and 'SQLITE_CONSTRAINT_UNIQUE' is for SQLite
385+
386+
let error = catchedError
387+
if (typeof catchedError === 'object' && 'cause' in catchedError) {
388+
error = catchedError.cause
389+
}
390+
385391
if (error.code === '23505' || error.code === 'SQLITE_CONSTRAINT_UNIQUE') {
386392
let fieldName: null | string = null
387393
// We need to try and find the right constraint for the field but if we can't we fallback to a generic message

0 commit comments

Comments
 (0)