onAPIError not working

Hello, When i use onAPIError in the auth config and try to log the error there is no logs in the console. Is there a way to use it ? I followed the docs
8 Replies
KiNFiSH
KiNFiSH3w ago
can u pls share how you actually configured it
SxYxuse
SxYxuseOP3w ago
Yes sure, like in the docs:
import { betterAuth } from "better-auth";
export const auth = betterAuth({
//… code above
onAPIError: {
throw: true,
onError: (error, ctx) => {
// Custom error handling
console.error("Auth error:", error);
},
errorURL: "/auth/error"
},
})
import { betterAuth } from "better-auth";
export const auth = betterAuth({
//… code above
onAPIError: {
throw: true,
onError: (error, ctx) => {
// Custom error handling
console.error("Auth error:", error);
},
errorURL: "/auth/error"
},
})
KiNFiSH
KiNFiSH3w ago
can u toggle the throw to false .. ig it is been throwing an error before it is catching and logging it
SxYxuse
SxYxuseOP3w ago
Same issue I try with auth.api.checkOrganizationSlug with an existing slug to get an error It don’t work But I get the ApiError in the console like before Seem the onAPIError is not reached Will you fix this issue in next release ?
KiNFiSH
KiNFiSH3w ago
yeah yeah def.
SxYxuse
SxYxuseOP3w ago
@bekacru sorry for the ping, should be great when onAPIError is fixed that we can transform the error like rebuild it and than rethrow it
bekacru
bekacru3w ago
will do!
srd
srd2w ago
Hey, do you have an idea on when this will be looked at?

Did you find this page helpful?