Skip to content

Commit f5fef18

Browse files
committed
feat: standardize stream completion error handling
1 parent 7c0f406 commit f5fef18

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/client/components/Chat/error.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { t } from 'i18next'
22
import { enqueueSnackbar } from 'notistack'
33

4+
/**
5+
* Handle error messages related to completion stream creation
6+
*/
47
export const handleCompletionStreamError = (err: any, file: string) => {
58
if (err?.name === 'AbortError' || !err) return
69

@@ -10,8 +13,8 @@ export const handleCompletionStreamError = (err: any, file: string) => {
1013
enqueueSnackbar(t('error:tooLargeFile'), { variant: 'error' })
1114
} else if (error === 'Error parsing file' && file) {
1215
enqueueSnackbar(t('error:fileParsingError'), { variant: 'error' })
13-
} else if (!error && typeof err === 'string') {
14-
enqueueSnackbar(err, { variant: 'error' })
16+
} else if (error === 'Creating a stream took too long') {
17+
enqueueSnackbar(t('error:streamCreationTimeout'), { variant: 'warning' })
1518
} else {
1619
enqueueSnackbar(t('error:unexpected'), { variant: 'error' })
1720
}

src/client/components/Chat/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ const Chat = () => {
258258
) => {
259259
if (!abortController || abortController.signal.aborted) return
260260

261-
abortController?.abort('Creating a stream took too long')
261+
abortController?.abort(new Error('Creating a stream took too long'))
262262
const newAbortController = new AbortController()
263263
setStreamController(newAbortController)
264264

src/client/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@
9090
"noAccessInfo": "You do not currently have access to CurreChat",
9191
"tooLargeFile": "The file is too large",
9292
"fileParsingError": "Parsing the file failed",
93-
"invalidFileType": "Invalid file type"
93+
"invalidFileType": "Invalid file type",
94+
"streamCreationTimeout": "Creating the stream timed out, retrying"
9495
},
9596
"chats": {
9697
"header": "Current course chats",

src/client/locales/fi.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
"noAccessInfo": "Sinulla ei tällä hetkellä ole käyttöoikeuksia CurreChattiin",
9999
"tooLargeFile": "Tiedosto on liian suuri",
100100
"fileParsingError": "Tiedoston lukeminen epäonnistui",
101-
"invalidFileType": "Tiedostotyyppiä ei tueta"
101+
"invalidFileType": "Tiedostotyyppiä ei tueta",
102+
"streamCreationTimeout": "Vastauksen luonti kesti liian kauan, yritetään uudelleen"
102103
},
103104
"admin": {
104105
"showing": "Näytetään",

0 commit comments

Comments
 (0)