diff --git a/src/plugins/vis_type_vega/public/components/vega_vis_editor.tsx b/src/plugins/vis_type_vega/public/components/vega_vis_editor.tsx index 23c6d2975f3c..73abdd4788bc 100644 --- a/src/plugins/vis_type_vega/public/components/vega_vis_editor.tsx +++ b/src/plugins/vis_type_vega/public/components/vega_vis_editor.tsx @@ -97,7 +97,15 @@ function VegaVisEditor({ stateParams, setValue }: VisOptionsProps) { const text2vega = getText2Vega(); const subscription = text2vega.getResult$().subscribe((result) => { if (result) { - setValue('spec', JSON.stringify(result, null, 4)); + if (result.error) { + getNotifications().toasts.addError(result.error, { + title: i18n.translate('visTypeVega.editor.llmError', { + defaultMessage: 'Error while executing text to vega', + }), + }); + } else { + setValue('spec', JSON.stringify(result, null, 4)); + } } }); diff --git a/src/plugins/vis_type_vega/public/text_to_vega.ts b/src/plugins/vis_type_vega/public/text_to_vega.ts index f217b1bd6c38..6718a283f521 100644 --- a/src/plugins/vis_type_vega/public/text_to_vega.ts +++ b/src/plugins/vis_type_vega/public/text_to_vega.ts @@ -30,7 +30,7 @@ Just reply with the json based Vega-Lite object, do not include any other conten export class Text2Vega { input$ = new BehaviorSubject({ input: '' }); - result$: Observable; + result$: Observable | { error: any }>; status$ = new BehaviorSubject<'RUNNING' | 'STOPPED'>('STOPPED'); http: HttpSetup;