forked from bai/curriculum-project-hub
feat: validate team slug format and improve error handling in team creation
This commit is contained in:
@@ -35,9 +35,11 @@ export async function handleRouteError(reply: FastifyReply, err: unknown): Promi
|
||||
await sendError(reply, mapped.statusCode, mapped.code, mapped.message);
|
||||
return;
|
||||
}
|
||||
reply.log.error({ err }, "unmapped route error");
|
||||
await sendError(reply, 500, "internal_error", "internal error");
|
||||
return;
|
||||
}
|
||||
reply.log.error({ err }, "unmapped route error");
|
||||
await sendError(reply, 500, "internal_error", "internal error");
|
||||
}
|
||||
|
||||
@@ -71,7 +73,8 @@ function mapDomainError(message: string): { statusCode: number; code: string; me
|
||||
lower.includes("is required") ||
|
||||
lower.includes("already") ||
|
||||
lower.includes("invalid") ||
|
||||
lower.includes("accepts only")
|
||||
lower.includes("accepts only") ||
|
||||
lower.includes("must be")
|
||||
) {
|
||||
return { statusCode: 400, code: "bad_request", message };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user