Add better error bubble-up

This commit is contained in:
Jack Kingsman
2026-01-13 01:19:15 -08:00
parent 40b672d569
commit 760bd0f7d6
7 changed files with 97 additions and 36 deletions
@@ -1,4 +1,5 @@
import { useState, useCallback, useEffect, useRef } from 'react';
import { toast } from '../components/ui/sonner';
import { api } from '../api';
import type { Conversation, Message } from '../types';
@@ -61,6 +62,9 @@ export function useConversationMessages(
setHasOlderMessages(data.length >= MESSAGE_PAGE_SIZE);
} catch (err) {
console.error('Failed to fetch messages:', err);
toast.error('Failed to load messages', {
description: err instanceof Error ? err.message : 'Check your connection',
});
} finally {
if (showLoading) {
setMessagesLoading(false);
@@ -93,6 +97,9 @@ export function useConversationMessages(
setHasOlderMessages(data.length >= MESSAGE_PAGE_SIZE);
} catch (err) {
console.error('Failed to fetch older messages:', err);
toast.error('Failed to load older messages', {
description: err instanceof Error ? err.message : 'Check your connection',
});
} finally {
setLoadingOlder(false);
}