Skip to content

Commit

Permalink
Add error handling for embeddable
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Jun 18, 2020
1 parent 6879ea7 commit 6d51a08
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

import { i18n } from '@kbn/i18n';
import { VisSavedObject, VisualizeEmbeddableContract } from 'src/plugins/visualizations/public';
import { SearchSourceFields } from 'src/plugins/data/public';
import { SavedObject } from 'src/plugins/saved_objects/public';
Expand All @@ -32,6 +33,7 @@ export const getVisualizationInstance = async (
createVisEmbeddableFromObject,
savedObjects,
savedVisualizations,
toastNotifications,
}: VisualizeServices,
/**
* opts can be either a saved visualization id passed as string,
Expand Down Expand Up @@ -62,6 +64,16 @@ export const getVisualizationInstance = async (
id: '',
})) as VisualizeEmbeddableContract;

embeddableHandler.getOutput$().subscribe((output) => {
if (output.error) {
toastNotifications.addError(output.error, {
title: i18n.translate('visualize.error.title', {
defaultMessage: 'Visualization error',
}),
});
}
});

let savedSearch: SavedObject | undefined;

if (vis.data.savedSearchId) {
Expand Down

0 comments on commit 6d51a08

Please sign in to comment.