mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
14 lines
393 B
TypeScript
14 lines
393 B
TypeScript
import { NextResponse } from "next/server";
|
|
|
|
export async function withErrorHandling(handler: () => Promise<Response | NextResponse>) {
|
|
try {
|
|
return await handler();
|
|
} catch (error) {
|
|
console.error("Error caught in centralized handler:", error);
|
|
return NextResponse.json(
|
|
{ error: (error as Error).message || "Internal Server Error" },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|