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:
@@ -12,6 +12,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"
|
||||
import {
|
||||
ArrowLeft, Plus, Trash2, Send, Play, Pause, Users, Mail, Clock,
|
||||
} from "lucide-react"
|
||||
import { toast } from "sonner"
|
||||
|
||||
export default function CampaignDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
const { id } = use(params)
|
||||
@@ -29,7 +30,7 @@ export default function CampaignDetailPage({ params }: { params: Promise<{ id: s
|
||||
try {
|
||||
const res = await fetch(`/api/campaigns/${id}`)
|
||||
if (res.ok) setCampaign(await res.json())
|
||||
} catch { /* ignore */ }
|
||||
} catch (e) { console.error("Failed to load campaign", e); toast.error("Failed to load campaign") }
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ export default function CampaignDetailPage({ params }: { params: Promise<{ id: s
|
||||
})
|
||||
setNewStep({ subject: "", bodyText: "", delayDays: 3 })
|
||||
fetchCampaign()
|
||||
} catch { /* ignore */ }
|
||||
} catch (e) { console.error("Failed to add step", e); toast.error("Failed to add step") }
|
||||
setAddingStep(false)
|
||||
}
|
||||
|
||||
@@ -68,7 +69,7 @@ export default function CampaignDetailPage({ params }: { params: Promise<{ id: s
|
||||
setLeadSearch("")
|
||||
setSearchResults([])
|
||||
fetchCampaign()
|
||||
} catch { /* ignore */ }
|
||||
} catch (e) { console.error("Failed to subscribe leads", e); toast.error("Failed to subscribe leads") }
|
||||
setSubscribing(false)
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ export default function CampaignDetailPage({ params }: { params: Promise<{ id: s
|
||||
const res = await fetch(`/api/campaigns/${id}/send`, { method: "POST" })
|
||||
const data = await res.json()
|
||||
if (data.sent > 0) fetchCampaign()
|
||||
} catch { /* ignore */ }
|
||||
} catch (e) { console.error("Failed to send campaign", e); toast.error("Failed to send campaign") }
|
||||
setSending(false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user