Skip to content

Commit cee985f

Browse files
authored
Merge pull request #441 from nextcloud/fix/userfacingerrormessages
fix: Use userFacingErrorMessage from TaskProcessing API if available
2 parents 16b08fa + 1f3e40f commit cee985f

1 file changed

Lines changed: 42 additions & 14 deletions

File tree

src/assistant.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,17 @@ export async function openAssistantForm({
136136
view.outputs = finishedTask?.output
137137
}
138138
} else if (finishedTask.status === TASK_STATUS_STRING.failed) {
139-
showError(
140-
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
141-
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
142-
)
139+
if (finishedTask.userFacingErrorMessage) {
140+
showError(
141+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
142+
+ ': ' + finishedTask.userFacingErrorMessage,
143+
)
144+
} else {
145+
showError(
146+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
147+
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
148+
)
149+
}
143150
console.error('[assistant] Task failed', finishedTask)
144151
view.outputs = null
145152
}
@@ -220,10 +227,17 @@ export async function openAssistantForm({
220227
view.outputs = finishedTask?.output
221228
view.selectedTaskId = finishedTask?.id
222229
} else if (finishedTask.status === TASK_STATUS_STRING.failed) {
223-
showError(
224-
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
225-
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
226-
)
230+
if (finishedTask.userFacingErrorMessage) {
231+
showError(
232+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
233+
+ ': ' + finishedTask.userFacingErrorMessage,
234+
)
235+
} else {
236+
showError(
237+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
238+
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
239+
)
240+
}
227241
console.error('[assistant] Task failed', finishedTask)
228242
view.outputs = null
229243
}
@@ -564,10 +578,17 @@ export async function openAssistantTask(
564578
if (finishedTask.status === TASK_STATUS_STRING.successful) {
565579
view.outputs = finishedTask?.output
566580
} else if (finishedTask.status === TASK_STATUS_STRING.failed) {
567-
showError(
568-
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
581+
if (finishedTask.userFacingErrorMessage) {
582+
showError(
583+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
584+
+ ': ' + finishedTask.userFacingErrorMessage,
585+
)
586+
} else {
587+
showError(
588+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
569589
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
570-
)
590+
)
591+
}
571592
console.error('[assistant] Task failed', finishedTask)
572593
view.outputs = null
573594
}
@@ -645,10 +666,17 @@ export async function openAssistantTask(
645666
view.outputs = finishedTask?.output
646667
view.selectedTaskId = finishedTask?.id
647668
} else if (finishedTask.status === TASK_STATUS_STRING.failed) {
648-
showError(
649-
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
669+
if (finishedTask.userFacingErrorMessage) {
670+
showError(
671+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
672+
+ ': ' + finishedTask.userFacingErrorMessage,
673+
)
674+
} else {
675+
showError(
676+
t('assistant', 'The server failed to process your task with ID {id}', { id: finishedTask.id })
650677
+ '. ' + t('assistant', 'Please inform the server administrators of this issue.'),
651-
)
678+
)
679+
}
652680
console.error('[assistant] Task failed', finishedTask)
653681
view.outputs = null
654682
}

0 commit comments

Comments
 (0)