From 10213016568201e3771249b00373cb2fa9601679 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Sun, 26 Jul 2026 16:34:06 +0700 Subject: [PATCH] fix: add error logging for various API calls across components --- .../src/app/(dashboard)/analysis/page.tsx | 4 ++-- .../src/app/(dashboard)/dashboard/page.tsx | 8 +++---- .../src/app/(dashboard)/messages/page.tsx | 8 +++---- .../src/app/(dashboard)/voice/page.tsx | 3 ++- .../src/components/chatbot/chatbot.tsx | 7 +++--- .../src/components/landing/live-stats.tsx | 4 ++-- services/frontend/src/hooks/use-dashboard.ts | 16 +++++++------- services/frontend/src/hooks/use-media.ts | 20 ++++++++--------- services/frontend/src/hooks/use-messages.ts | 22 ++++++++++--------- services/frontend/src/hooks/use-recordings.ts | 8 +++---- services/frontend/src/hooks/use-voice.ts | 7 +++--- 11 files changed, 56 insertions(+), 51 deletions(-) diff --git a/services/frontend/src/app/(dashboard)/analysis/page.tsx b/services/frontend/src/app/(dashboard)/analysis/page.tsx index e54f007..924563e 100644 --- a/services/frontend/src/app/(dashboard)/analysis/page.tsx +++ b/services/frontend/src/app/(dashboard)/analysis/page.tsx @@ -29,8 +29,8 @@ export default function AnalysisPage() { const { messagesApi } = await import("@/lib/api"); try { await messagesApi.reanalyze(id); - } catch { - /* ignore */ + } catch (err) { + console.error("analysis/reanalyze:", err); } }, []); diff --git a/services/frontend/src/app/(dashboard)/dashboard/page.tsx b/services/frontend/src/app/(dashboard)/dashboard/page.tsx index 27b89d1..e8ea065 100644 --- a/services/frontend/src/app/(dashboard)/dashboard/page.tsx +++ b/services/frontend/src/app/(dashboard)/dashboard/page.tsx @@ -82,8 +82,8 @@ export default function DashboardPage() { const detail = await dashboardApi.getUserDetail(userId); setActiveUser(detail); setView("user-detail"); - } catch { - /* ignore */ + } catch (err) { + console.error("dashboard/userDetail:", err); } }} /> @@ -97,8 +97,8 @@ export default function DashboardPage() { const detail = await dashboardApi.getChannelDetail(chId); setActiveChannel(detail); setView("channel-detail"); - } catch { - /* ignore */ + } catch (err) { + console.error("dashboard/channelDetail:", err); } }} /> diff --git a/services/frontend/src/app/(dashboard)/messages/page.tsx b/services/frontend/src/app/(dashboard)/messages/page.tsx index 55a752d..e85f54c 100644 --- a/services/frontend/src/app/(dashboard)/messages/page.tsx +++ b/services/frontend/src/app/(dashboard)/messages/page.tsx @@ -121,8 +121,8 @@ export default function MessagesPage() { const { messagesApi } = await import("@/lib/api"); try { await messagesApi.reanalyze(id); - } catch { - /* ignore */ + } catch (err) { + console.error("messages/reanalyze:", err); } }, []); @@ -131,8 +131,8 @@ export default function MessagesPage() { const { messagesApi } = await import("@/lib/api"); try { await messagesApi.reanalyzeBatch(guildId); - } catch { - /* ignore */ + } catch (err) { + console.error("messages/reanalyzeBatch:", err); } }, [guildId]); diff --git a/services/frontend/src/app/(dashboard)/voice/page.tsx b/services/frontend/src/app/(dashboard)/voice/page.tsx index f275ce9..a591417 100644 --- a/services/frontend/src/app/(dashboard)/voice/page.tsx +++ b/services/frontend/src/app/(dashboard)/voice/page.tsx @@ -238,7 +238,8 @@ export default function VoicePage() { await voiceApi.sendCommand( checked ? "voice:transmit:start" : "voice:transmit:stop", ); - } catch { + } catch (err) { + console.error("voice/mic:", err); setMicActive(!checked); } }} diff --git a/services/frontend/src/components/chatbot/chatbot.tsx b/services/frontend/src/components/chatbot/chatbot.tsx index a3721c1..b311c2e 100644 --- a/services/frontend/src/components/chatbot/chatbot.tsx +++ b/services/frontend/src/components/chatbot/chatbot.tsx @@ -51,8 +51,8 @@ export function Chatbot() { try { await chatbotApi.clearHistory(); setMessages([]); - } catch { - // ignore + } catch (err) { + console.error("chatbot/clearHistory:", err); } }, []); @@ -78,7 +78,8 @@ export function Chatbot() { timestamp: resp.timestamp, }, ]); - } catch { + } catch (err) { + console.error("chatbot/send:", err); setMessages((prev) => [ ...prev, { diff --git a/services/frontend/src/components/landing/live-stats.tsx b/services/frontend/src/components/landing/live-stats.tsx index ed19819..a498a61 100644 --- a/services/frontend/src/components/landing/live-stats.tsx +++ b/services/frontend/src/components/landing/live-stats.tsx @@ -43,8 +43,8 @@ export function LiveStats() { guildCount: guilds.length, wsConnected: false, }); - } catch { - // ignore + } catch (err) { + console.error("live-stats:", err); } finally { if (!cancelled) setLoading(false); } diff --git a/services/frontend/src/hooks/use-dashboard.ts b/services/frontend/src/hooks/use-dashboard.ts index ae212d2..a2b9446 100644 --- a/services/frontend/src/hooks/use-dashboard.ts +++ b/services/frontend/src/hooks/use-dashboard.ts @@ -59,8 +59,8 @@ export function useUsers(): UseUsersReturn { try { const result = await dashboardApi.listUsers(20, undefined, q); setUsers(result.data); - } catch { - // silently fail + } catch (err) { + console.error("useUsers:", err); } finally { setLoading(false); } @@ -104,8 +104,8 @@ export function useChannels(guildId: string): UseChannelsReturn { guildId || undefined, ); setChannels(result.data); - } catch { - // silently fail + } catch (err) { + console.error("useChannels:", err); } finally { setLoading(false); } @@ -137,8 +137,8 @@ export function useUserDetail() { try { const detail = await dashboardApi.getUserDetail(userId); setUser(detail); - } catch { - // ignore + } catch (err) { + console.error("useUserDetail:", err); } finally { setLoading(false); } @@ -158,8 +158,8 @@ export function useChannelDetail() { try { const detail = await dashboardApi.getChannelDetail(channelId); setChannel(detail); - } catch { - // ignore + } catch (err) { + console.error("useChannelDetail:", err); } finally { setLoading(false); } diff --git a/services/frontend/src/hooks/use-media.ts b/services/frontend/src/hooks/use-media.ts index d2c233f..05c0cae 100644 --- a/services/frontend/src/hooks/use-media.ts +++ b/services/frontend/src/hooks/use-media.ts @@ -27,8 +27,8 @@ export function useMediaState(): UseMediaStateReturn { try { const state = await voiceApi.getMediaStatus(); setMediaState(state); - } catch { - // ignore + } catch (err) { + console.error("useMediaState/refresh:", err); } }, []); @@ -36,8 +36,8 @@ export function useMediaState(): UseMediaStateReturn { try { const state = await voiceApi.mediaQueue(url, "music"); setMediaState(state); - } catch { - // ignore + } catch (err) { + console.error("useMediaState/queue:", err); } }, []); @@ -45,8 +45,8 @@ export function useMediaState(): UseMediaStateReturn { try { const state = await voiceApi.mediaSkip(); setMediaState(state); - } catch { - // ignore + } catch (err) { + console.error("useMediaState/skip:", err); } }, []); @@ -54,8 +54,8 @@ export function useMediaState(): UseMediaStateReturn { try { const state = await voiceApi.mediaStop(); setMediaState(state); - } catch { - // ignore + } catch (err) { + console.error("useMediaState/stop:", err); } }, []); @@ -64,8 +64,8 @@ export function useMediaState(): UseMediaStateReturn { try { const state = await voiceApi.mediaVolume(vol); setMediaState(state); - } catch { - // ignore + } catch (err) { + console.error("useMediaState/setVolume:", err); } }, []); diff --git a/services/frontend/src/hooks/use-messages.ts b/services/frontend/src/hooks/use-messages.ts index 46133f0..7fd3d67 100644 --- a/services/frontend/src/hooks/use-messages.ts +++ b/services/frontend/src/hooks/use-messages.ts @@ -70,8 +70,8 @@ export function useMessages( setMessages((prev) => [...prev, ...result.data]); setCursor(result.nextCursor); setHasMore(result.nextCursor !== null); - } catch { - // ignore + } catch (err) { + console.error("useMessages/loadMore:", err); } finally { setLoadingMore(false); } @@ -119,7 +119,7 @@ export function useTextChannels(guildId: string): UseTextChannelsReturn { voiceApi .getTextChannels(guildId) .then(setChannels) - .catch(() => {}) + .catch((err) => console.error("useTextChannels:", err)) .finally(() => setLoading(false)); }, [guildId]); @@ -147,7 +147,8 @@ export function useSearch(): UseSearchReturn { try { const result = await messagesApi.search(query, 50); setResults(result.results); - } catch { + } catch (err) { + console.error("useSearch:", err); setResults([]); } finally { setSearching(false); @@ -167,8 +168,8 @@ export function useImages(guildId: string) { try { const result = await messagesApi.getImages(guildId, 50); setImages(result.data); - } catch { - // silently fail + } catch (err) { + console.error("useImages:", err); } }, [guildId]); @@ -184,8 +185,8 @@ export function useReview(channelId?: string) { try { const result = await messagesApi.getReview(50, channelId || undefined); setReviews(result.results); - } catch { - // silently fail + } catch (err) { + console.error("useReview:", err); } }, [channelId]); @@ -217,9 +218,10 @@ export function useMessageDetail(): UseMessageDetailReturn { messagesApi .getAttachments(detail.channel_id, 10) .then((res) => setAttachments(res.data)) - .catch(() => {}); + .catch((err) => console.error("useMessageDetail/attachments:", err)); } - } catch { + } catch (err) { + console.error("useMessageDetail:", err); setMessage(null); } finally { setLoading(false); diff --git a/services/frontend/src/hooks/use-recordings.ts b/services/frontend/src/hooks/use-recordings.ts index 543590d..a5d59f3 100644 --- a/services/frontend/src/hooks/use-recordings.ts +++ b/services/frontend/src/hooks/use-recordings.ts @@ -28,8 +28,8 @@ export function useRecordings(): UseRecordingsReturn { try { const result = await recordingsApi.list(50); setRecordings(result.items); - } catch { - // ignore + } catch (err) { + console.error("useRecordings/refresh:", err); } finally { setLoading(false); } @@ -39,8 +39,8 @@ export function useRecordings(): UseRecordingsReturn { try { await recordingsApi.delete(id); setRecordings((prev) => prev.filter((r) => r.id !== id)); - } catch { - // ignore + } catch (err) { + console.error("useRecordings/remove:", err); } }, []); diff --git a/services/frontend/src/hooks/use-voice.ts b/services/frontend/src/hooks/use-voice.ts index 05f86ad..a756d36 100644 --- a/services/frontend/src/hooks/use-voice.ts +++ b/services/frontend/src/hooks/use-voice.ts @@ -23,8 +23,8 @@ export function useVoiceStatus(): UseVoiceStatusReturn { try { const status = await voiceApi.getStatus(); setVoiceStatus(status); - } catch { - // ignore + } catch (err) { + console.error("useVoiceStatus:", err); } }, []); @@ -48,7 +48,8 @@ export function useVoiceChannels(): UseVoiceChannelsReturn { try { const ch = await voiceApi.getVoiceChannels(guildId); setChannels(ch); - } catch { + } catch (err) { + console.error("useVoiceChannels:", err); setChannels([]); } finally { setLoading(false);