Add descriptive error messages across all API routes and toast notifications on client pages
Build & Auto-Repair / build (push) Has been cancelled
Build & Auto-Repair / build (push) Has been cancelled
- 86 catch blocks in 49 API route files now return the actual error message via error.message
- 14 campaign/lead/config catch blocks that lacked console.error now log errors
- 17 client pages/components now show toast.error notifications on API failures
- Silent .catch(() => {}) and finally-only try blocks now surface errors to users
This commit is contained in:
@@ -25,7 +25,8 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json(result.rows)
|
||||
} catch (error) {
|
||||
console.error("Custom fields API error:", error)
|
||||
return NextResponse.json({ error: "Failed to load custom fields" }, { status: 500 })
|
||||
const message = error instanceof Error ? error.message : "Failed to load custom fields"
|
||||
return NextResponse.json({ error: message }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +63,8 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: "A field with this key already exists for this entity" }, { status: 409 })
|
||||
}
|
||||
console.error("Custom fields POST error:", error)
|
||||
return NextResponse.json({ error: "Failed to create custom field" }, { status: 500 })
|
||||
const message = error instanceof Error ? error.message : "Failed to create custom field"
|
||||
return NextResponse.json({ error: message }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +108,8 @@ export async function PATCH(request: NextRequest) {
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
console.error("Custom fields PATCH error:", error)
|
||||
return NextResponse.json({ error: "Failed to update custom field" }, { status: 500 })
|
||||
const message = error instanceof Error ? error.message : "Failed to update custom field"
|
||||
return NextResponse.json({ error: message }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +123,7 @@ export async function DELETE(request: NextRequest) {
|
||||
return NextResponse.json({ success: true })
|
||||
} catch (error) {
|
||||
console.error("Custom fields DELETE error:", error)
|
||||
return NextResponse.json({ error: "Failed to delete custom field" }, { status: 500 })
|
||||
const message = error instanceof Error ? error.message : "Failed to delete custom field"
|
||||
return NextResponse.json({ error: message }, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user