fix: rethrow error from db hooks if it is APIError instances

This commit is contained in:
Bereket Engida
2025-04-12 23:45:33 +03:00
parent ac084b1b73
commit 45f43dd6f4

View File

@@ -199,6 +199,9 @@ export const signUpEmail = <O extends BetterAuthOptions>() =>
if (isDevelopment) {
ctx.context.logger.error("Failed to create user", e);
}
if (e instanceof APIError) {
throw e;
}
throw new APIError("UNPROCESSABLE_ENTITY", {
message: BASE_ERROR_CODES.FAILED_TO_CREATE_USER,
details: e,