Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
How to handle database errors - Better Auth
BA
Better Auth
•
12mo ago
•
19 replies
quickFastJoe
How to handle database errors
2025
-03
-
0
4
T
2
2
:
0
1
:39
.315Z ERROR
[Better Auth
]
: error error
: duplicate key value violates unique constraint
"user
_phoneNumber
_key
"
at async POST
(src
/app
/api
/auth
/
[
.
.
.all
]
/route
.
t
s
:
8
:14
)
at async POST
(src
/app
/api
/auth
/
[
.
.
.all
]
/route
.
t
s
:
8
:14
)
6
|
7
| export const POST
= async
(req
: NextRequest
)
=
>
{
8
| const res
= await auth
.handler
(req
)
;
|
^
9
| return res
;
10
|
}
;
11
|
{
length
: 221
,
severity
:
'ERROR
'
,
code
:
'23505
'
,
detail
:
'Key
(
"phoneNumber
"
)
=
(
+1
(phonenumber
)
) already exists
.
'
,
hint
: undefined
,
position
: undefined
,
internalPosition
: undefined
,
internalQuery
: undefined
,
where
: undefined
,
schema
:
'public
'
,
table
:
'user
'
,
column
: undefined
,
dataType
: undefined
,
constraint
:
'user
_phoneNumber
_key
'
,
file
:
'nbtinsert
.c
'
,
line
:
'666
'
,
routine
:
'
_bt
_check
_unique
'
}
Better Auth
Join
9,988
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Similar Threads
How to handle phoneNumber.sendOtp errors ? Only 500 is returned
BA
Better Auth / help
10mo ago
How to handle optional params
BA
Better Auth / help
3mo ago
How to handle multi-tenant
BA
Better Auth / help
8mo ago
How to handle deleted user?
BA
Better Auth / help
8mo ago