API Error codes
Thanks for a great library! I want to display error messages in another language than English and am therefore interested to switch based on the
error.body.code
. So far I have come across the USER_ALREADY_EXISTS
code, but doing this manually is tedious - is there any list or reference for all possible error messages? All I can find is this, which is very sparse: https://www.better-auth.com/docs/concepts/api#error-handling.API | Better Auth
Better Auth API.
Solution:Jump to solution
```ts
type $ERROR_CODES = {
USER_NOT_FOUND: string;
FAILED_TO_CREATE_USER: string;
FAILED_TO_CREATE_SESSION: string;...
4 Replies
You can use the type authClient.$ERROR_CODES
Solution
Awesome! How did you find this?
I don’t know really lmao
I think I was bored and just testing authClient methods
And saw that there is an type exported