What if sending email failed?

For the code below, what if sendEmail failed, how can i catch the error on client side?
import { betterAuth } from "better-auth"
import { emailOTP } from "better-auth/plugins"

export const auth = betterAuth({
// ... other config options
plugins: [
emailOTP({
async sendVerificationOTP({ email, otp, type}) {
sendEmail(email, opt);
},
})
]
})
import { betterAuth } from "better-auth"
import { emailOTP } from "better-auth/plugins"

export const auth = betterAuth({
// ... other config options
plugins: [
emailOTP({
async sendVerificationOTP({ email, otp, type}) {
sendEmail(email, opt);
},
})
]
})
I am using resend, and got a error for resend when sending email:
{
statusCode: 403,
message: "...",
name: 'validation_error'
}
{
statusCode: 403,
message: "...",
name: 'validation_error'
}
but I can not get the error on client side.
1 Reply
jperusm
jperusm2w ago
I had a similar problem, the fix was to await for sendEmail to return response, otherwise it is a race condition.

Did you find this page helpful?