This commit is contained in:
Zeeshaun
2026-05-06 15:08:32 +00:00
parent b05a1a954b
commit 0de593c7d3
54 changed files with 4522 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
import { NextResponse } from "next/server";
import { ZodError } from "zod";
export function handleApiError(error: unknown) {
if (error instanceof ZodError) {
return NextResponse.json({ error: error.issues[0]?.message ?? "Validation failed." }, { status: 400 });
}
if (error instanceof Error) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
return NextResponse.json({ error: "Unexpected server error." }, { status: 500 });
}