Export error consts array for username plugin #901

Closed
opened 2026-03-13 08:09:12 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @modejota on GitHub (Mar 23, 2025).

Is this suited for github?

  • Yes, this is suited for github

Could the arrays with the error codes constants be exported? So that they can be accessed more easily in case of customizing the message or do some additional error handling?

Example given for the username plugin: Link to the code

authClient.$ERROR_CODES doesn't provide the username plugin errors

Describe the solution you'd like

Arrays of errors codes consts exported under some descriptive name so that they can be easily accessed, for example, when handling an error in a form.

Describe alternatives you've considered

I think solution is simple enough

Additional context

I've searched for ways to manage the error returned in a response with some consts, so I can do a switch. To know the values I've had to search through the source code as it doesn't seem to be mentioned in the documentation. I'd prefer to have a centralized source of truth from the package instead of managing a hardcoded string by myself.

Originally created by @modejota on GitHub (Mar 23, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Could the arrays with the error codes constants be exported? So that they can be accessed more easily in case of customizing the message or do some additional error handling? Example given for the username plugin: [Link to the code](https://github.com/better-auth/better-auth/blob/main/packages/better-auth/src/plugins/username/index.ts#L40) authClient.$ERROR_CODES doesn't provide the username plugin errors ### Describe the solution you'd like Arrays of errors codes consts exported under some descriptive name so that they can be easily accessed, for example, when handling an error in a form. ### Describe alternatives you've considered I think solution is simple enough ### Additional context I've searched for ways to manage the error returned in a response with some consts, so I can do a switch. To know the values I've had to search through the source code as it doesn't seem to be mentioned in the documentation. I'd prefer to have a centralized source of truth from the package instead of managing a hardcoded string by myself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#901