Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surface vis loader errors in the UI. #30594

Merged
merged 3 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

62 changes: 0 additions & 62 deletions src/legacy/ui/public/elasticsearch_errors/elasticsearch_error.js

This file was deleted.

21 changes: 0 additions & 21 deletions src/legacy/ui/public/elasticsearch_errors/index.js

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ import {
} from './types';
import { queryGeohashBounds } from './utils';

import { i18n } from '@kbn/i18n';
import { toastNotifications } from 'ui/notify';

interface EmbeddedVisualizeHandlerParams extends VisualizeLoaderParams {
Private: IPrivate;
queryFilter: any;
Expand Down Expand Up @@ -428,12 +431,47 @@ export class EmbeddedVisualizeHandler {
this.dataLoaderParams.inspectorAdapters = this.inspectorAdapters;

this.vis.filters = { timeRange: this.dataLoaderParams.timeRange };
this.vis.requestError = undefined;
this.vis.showRequestError = false;

return this.dataLoader
.fetch(this.dataLoaderParams)
.then(data => {
// Pipeline responses never throw errors, so we need to check for
// `type: 'error'`, and then throw so it can be caught below.
// TODO: We should revisit this after we have fully migrated
// to the new expression pipeline infrastructure.
if (data && data.type === 'error') {
throw data.error;
}

return this.dataLoader.fetch(this.dataLoaderParams).then(data => {
if (data && data.value) {
this.dataSubject.next(data.value);
}
return data;
if (data && data.value) {
this.dataSubject.next(data.value);
}
return data;
})
.catch(this.handleDataLoaderError);
};

/**
* When dataLoader returns an error, we need to make sure it surfaces in the UI.
*
* TODO: Eventually we should add some custom error messages for issues that are
* frequently encountered by users.
*/
private handleDataLoaderError = (error: any): void => {
// TODO: come up with a general way to cancel execution of pipeline expressions.
this.dataLoaderParams.searchSource.cancelQueued();

this.vis.requestError = error;
this.vis.showRequestError =
error.type && ['NO_OP_SEARCH_STRATEGY', 'UNSUPPORTED_QUERY'].includes(error.type);

toastNotifications.addDanger({
title: i18n.translate('common.ui.visualize.dataLoaderError', {
defaultMessage: 'Error in visualization',
}),
text: error.message,
});
};

Expand Down
2 changes: 0 additions & 2 deletions src/legacy/ui/public/visualize/loader/pipeline_data_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ export class PipelineDataLoader {
constructor(private readonly vis: Vis) {}

public async fetch(params: RequestHandlerParams): Promise<any> {
this.vis.requestError = undefined;
this.vis.showRequestError = false;
this.vis.pipelineExpression = buildPipeline(this.vis, params);

return await runPipeline(
Expand Down
Loading