Skip to content

Commit

Permalink
show error toast when getting error from text to vega execution
Browse files Browse the repository at this point in the history
Signed-off-by: Yulong Ruan <ruanyl@amazon.com>
  • Loading branch information
ruanyl committed Jun 4, 2024
1 parent 0edeade commit 7a829b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/plugins/vis_type_vega/public/components/vega_vis_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@ function VegaVisEditor({ stateParams, setValue }: VisOptionsProps<VisParams>) {
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));
}
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/public/text_to_vega.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string | Error>;
result$: Observable<Record<string, any> | { error: any }>;
status$ = new BehaviorSubject<'RUNNING' | 'STOPPED'>('STOPPED');
http: HttpSetup;

Expand Down

0 comments on commit 7a829b8

Please sign in to comment.