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
KiNFiSH2w ago
can u pls share how you actually configured it
SxYxuse
SxYxuseOP2w 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
KiNFiSH2w ago
can u toggle the throw to false .. ig it is been throwing an error before it is catching and logging it
SxYxuse
SxYxuseOP2w 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
KiNFiSH2w ago
yeah yeah def.
SxYxuse
SxYxuseOP7d 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
bekacru7d ago
will do!
srd
srdthis hour
Hey, do you have an idea on when this will be looked at?

Did you find this page helpful?