build fix

This commit is contained in:
alma 2025-05-05 13:22:16 +02:00
parent 9ebfd23321
commit 67fe023cbc
2 changed files with 8 additions and 2 deletions

View File

@ -127,7 +127,10 @@ export async function DELETE(
} catch (error) {
console.error("Error deleting announcement:", error);
const errorMessage = error instanceof Error ? error.message : "Unknown error";
const errorCode = error.code || "UNKNOWN";
// Use a type guard to safely access the 'code' property
const errorCode = typeof error === 'object' && error !== null && 'code' in error
? (error as { code: unknown }).code?.toString() || "UNKNOWN"
: "UNKNOWN";
return NextResponse.json({
error: "Failed to delete announcement",

View File

@ -116,7 +116,10 @@ export async function POST(req: NextRequest) {
console.error("Error creating announcement:", error);
// Return more detailed error information
const errorMessage = error instanceof Error ? error.message : "Unknown error";
const errorCode = error.code || "UNKNOWN";
// Use a type guard to safely access the 'code' property
const errorCode = typeof error === 'object' && error !== null && 'code' in error
? (error as { code: unknown }).code?.toString() || "UNKNOWN"
: "UNKNOWN";
return NextResponse.json({
error: "Failed to create announcement",