diff options
| author | Taylor Mullen <[email protected]> | 2025-04-18 17:47:49 -0400 |
|---|---|---|
| committer | N. Taylor Mullen <[email protected]> | 2025-04-18 17:51:16 -0400 |
| commit | e7fa39112a9b528bfe5a36a7b8b806de645eb977 (patch) | |
| tree | ec91ed950317d26b41674f08766bdb525bd5d43c /packages/cli/src/ui/hooks/useGeminiStream.ts | |
| parent | dfae3f62848f0c8c175f0e992a479c3bf49e50ed (diff) | |
Manually fix hooks and utils linting errors (partial)
- More changes are to come, this is truly a partial change in order to not disrupt as many people as possible.
Part of https://b.corp.google.com/issues/411384603
Diffstat (limited to 'packages/cli/src/ui/hooks/useGeminiStream.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useGeminiStream.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/packages/cli/src/ui/hooks/useGeminiStream.ts b/packages/cli/src/ui/hooks/useGeminiStream.ts index 0b62a40b..f97f5e27 100644 --- a/packages/cli/src/ui/hooks/useGeminiStream.ts +++ b/packages/cli/src/ui/hooks/useGeminiStream.ts @@ -5,6 +5,7 @@ import { type Chat, type PartListUnion } from '@google/genai'; import { HistoryItem } from '../types.js'; import { processGeminiStream , StreamingState } from '../../core/gemini-stream.js'; import { globalConfig } from '../../config/config.js'; +import { getErrorMessage, isNodeError } from '../../utils/errors.js'; const addHistoryItem = ( setHistory: React.Dispatch<React.SetStateAction<HistoryItem[]>>, @@ -36,9 +37,9 @@ export const useGeminiStream = ( if (!geminiClientRef.current) { try { geminiClientRef.current = new GeminiClient(globalConfig); - } catch (error: any) { + } catch (error: unknown) { setInitError( - `Failed to initialize client: ${error.message || 'Unknown error'}`, + `Failed to initialize client: ${getErrorMessage(error) || 'Unknown error'}`, ); } } @@ -136,17 +137,17 @@ export const useGeminiStream = ( addHistoryItem: addHistoryItemFromStream, currentToolGroupIdRef, }); - } catch (error: any) { + } catch (error: unknown) { // (Error handling for stream initiation remains the same) console.error('Error initiating stream:', error); - if (error.name !== 'AbortError') { + if (!isNodeError(error) || error.name !== 'AbortError') { // Use historyUpdater's function potentially? Or keep addHistoryItem here? // Keeping addHistoryItem here for direct errors from this scope. addHistoryItem( setHistory, { type: 'error', - text: `[Error starting stream: ${error.message}]`, + text: `[Error starting stream: ${getErrorMessage(error)}]`, }, getNextMessageId(userMessageTimestamp), ); |
