[GH-ISSUE #8812] Access internal adapter errors #11199

Open
opened 2026-04-13 07:32:57 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @Raepheles on GitHub (Mar 28, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8812

Originally assigned to: @ping-maxwell on GitHub.

Is this suited for github?

  • Yes, this is suited for github

As far as I can see, better-auth swallows all errors thrown from the internal adapter and just returns its own APIError instead. This results in a loss of information that was present in the internal error.

In my case I have an additional unique field slug on my User table. Users can enter this field while registering. In the case that the user enters a value for slug that already exists in the User table, I need to be able to show the proper error on the form, notifying the user that this slug is taken. However as things stand right now, I just get UNPROCESSABLE_ENTITY error with Failed to create user message from better-auth's signIn method, and I have no way of knowing why it has failed. Meanwhile prisma error has all this information in its own error object.

Describe the solution you'd like

In my opinion, better-auth shouldn't just log the internal adapter error, but also add it to their APIError or provide some other way to retrieve internal errors.

Describe alternatives you've considered

So in order to get around this, I need to query User table, to check if the slug is taken and then try to insert the new user. Whereas if I had access to the prisma error, I wouldn't need to do that. Not only that but also this solution isn't preferable due to race conditions.

Alternatively I could simply show a generic error but that's also bad UX as the user will have no idea why they weren't able to register. So both solutions aren't desirable.

Additional context

No response

Originally created by @Raepheles on GitHub (Mar 28, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8812 Originally assigned to: @ping-maxwell on GitHub. ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. As far as I can see, better-auth swallows all errors thrown from the internal adapter and just returns its own APIError instead. This results in a loss of information that was present in the internal error. In my case I have an additional unique field `slug` on my User table. Users can enter this field while registering. In the case that the user enters a value for `slug` that already exists in the User table, I need to be able to show the proper error on the form, notifying the user that this slug is taken. However as things stand right now, I just get `UNPROCESSABLE_ENTITY` error with `Failed to create user` message from better-auth's signIn method, and I have no way of knowing why it has failed. Meanwhile prisma error has all this information in its own error object. ### Describe the solution you'd like In my opinion, better-auth shouldn't just log the internal adapter error, but also add it to their APIError or provide some other way to retrieve internal errors. ### Describe alternatives you've considered So in order to get around this, I need to query User table, to check if the slug is taken and then try to insert the new user. Whereas if I had access to the prisma error, I wouldn't need to do that. Not only that but also this solution isn't preferable due to race conditions. Alternatively I could simply show a generic error but that's also bad UX as the user will have no idea why they weren't able to register. So both solutions aren't desirable. ### Additional context _No response_
GiteaMirror added the databaseenhancement labels 2026-04-13 07:32:57 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#11199