Skip to content

Commit

Permalink
[Rollup] [Phase 1] Error handling - rollup search errors should be mo…
Browse files Browse the repository at this point in the history
…re user friendly
  • Loading branch information
alexwizp committed Jan 31, 2019
1 parent cc3cda4 commit 1540961
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
}
}

.tvbError__title,
.tvbError__additional,
.tvbError__stack {
margin-top: $euiSizeS;
Expand Down
8 changes: 7 additions & 1 deletion src/legacy/core_plugins/metrics/public/components/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ import React from 'react';
import _ from 'lodash';
import { FormattedMessage } from '@kbn/i18n/react';

const guidPattern = /\[[[a-f\d-\\]{36}\]/g;

function ErrorComponent(props) {
const { error } = props;
let additionalInfo;
const type = _.get(error, 'error.caused_by.type');
const type = _.get(error, 'error.caused_by.type') || _.get(error, 'error.type');
let reason = _.get(error, 'error.caused_by.reason');
const title = _.get(error, 'error.caused_by.title');

if (!reason) {
reason = _.get(error, 'message');
}

if (['runtime_exception', 'illegal_argument_exception'].includes(type)) {
reason = _.get(error, 'error.reason').replace(guidPattern, ``);
}

if (type === 'script_exception') {
const scriptStack = _.get(error, 'error.caused_by.script_stack');
reason = _.get(error, 'error.caused_by.caused_by.reason');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import topN from './vis_types/top_n/vis';
import table from './vis_types/table/vis';
import gauge from './vis_types/gauge/vis';
import markdown from './vis_types/markdown/vis';
import Error from './error';
import ErrorComponent from './error';
import NoData from './no_data';

const types = {
Expand All @@ -46,7 +46,7 @@ function Visualization(props) {
if (error) {
return (
<div className={props.className}>
<Error error={error} />
<ErrorComponent error={error} />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ export default (AbstractSearchStrategy, RollupSearchRequest, RollupSearchCapabil
super(server, callWithRequestFactory, RollupSearchRequest);
}

async getRollupData(req, indexPattern) {
getRollupData(req, indexPattern) {
const callWithRequest = this.getCallWithRequestInstance(req);
return await callWithRequest(ROLLUP_INDEX_CAPABILITIES_METHOD, {

return callWithRequest(ROLLUP_INDEX_CAPABILITIES_METHOD, {
indexPattern,
});
}).catch(() => Promise.resolve({}));
}

async checkForViability(req, indexPattern = DEFAULT_INDEX_PATTERN) {
Expand Down

0 comments on commit 1540961

Please sign in to comment.