How to catch validation errors when using a zod schema in an endpoint

I prefer adding a Zod schema to the create endpoint body param when creating custom plugins with API routes.

It provides great DX, however, I cannot figure out how to catch validation errors.

I always receive “Invalid body parameters.

From my understanding better-call throws APIError which causes better-auth to return a response.

I appreciate any guidance.
Was this page helpful?