Convert default to named exports - errors (#10986) (#11024)

* Convert default to named exports - errors

* Make all error classes use class syntax and extends

add tests

* Extending Error apparently doesn't work

* Merge PR #11004 to try to fix test failures
This commit is contained in:
Stacey Gammon 2017-04-04 15:18:04 -04:00 committed by GitHub
parent ee2219db38
commit 4855162ba9
20 changed files with 265 additions and 212 deletions

View file

@ -0,0 +1,70 @@
import expect from 'expect.js';
import {
SearchTimeout,
RequestFailure,
FetchFailure,
ShardFailure,
VersionConflict,
MappingConflict,
RestrictedMapping,
CacheWriteFailure,
FieldNotFoundInCache,
DuplicateField,
SavedObjectNotFound,
IndexPatternMissingIndices,
NoDefinedIndexPatterns,
NoDefaultIndexPattern,
PersistedStateError,
VislibError,
ContainerTooSmall,
InvalidWiggleSelection,
PieContainsAllZeros,
InvalidLogScaleValues,
StackedBarChartConfig,
NotEnoughData,
NoResults,
KbnError
} from 'ui/errors';
describe('ui/errors', () => {
const errors = [
new SearchTimeout(),
new RequestFailure('an error', { }),
new FetchFailure({ }),
new ShardFailure({ '_shards' : 5 }),
new VersionConflict({ }),
new MappingConflict({ }),
new RestrictedMapping('field', 'indexPattern'),
new CacheWriteFailure(),
new FieldNotFoundInCache('aname'),
new DuplicateField('dupfield'),
new SavedObjectNotFound('dashboard', '123'),
new IndexPatternMissingIndices(),
new NoDefinedIndexPatterns(),
new NoDefaultIndexPattern(),
new PersistedStateError(),
new VislibError('err'),
new ContainerTooSmall(),
new InvalidWiggleSelection(),
new PieContainsAllZeros(),
new InvalidLogScaleValues(),
new StackedBarChartConfig('err'),
new NotEnoughData('nodata'),
new NoResults()
];
errors.forEach(error => {
const className = error.constructor.name;
it(`${className} has a message`, () => {
expect(error.message).to.not.be.empty();
});
it(`${className} has a stack trace`, () => {
expect(error.stack).to.not.be.empty();
});
it (`${className} is an instance of KbnError`, () => {
expect(error instanceof KbnError).to.be(true);
});
});
});

View file

@ -1,8 +1,6 @@
import errors from 'ui/errors';
import { SavedObjectNotFound } from 'ui/errors';
export default function RedirectWhenMissingFn($location, kbnUrl, Notifier, Promise) {
const SavedObjectNotFound = errors.SavedObjectNotFound;
const notify = new Notifier();
/**

View file

@ -7,7 +7,7 @@
import _ from 'lodash';
import errors from 'ui/errors';
import { VersionConflict, RequestFailure } from 'ui/errors';
import RequestQueueProvider from 'ui/courier/_request_queue';
import FetchProvider from 'ui/courier/fetch/fetch';
@ -36,7 +36,7 @@ export default function (Promise, Private, es, esAdmin, kbnIndex) {
const client = [].concat(params.index).includes(kbnIndex) ? esAdmin : es;
return client[method](params)
.then(function (resp) {
if (resp.status === 409) throw new errors.VersionConflict(resp);
if (resp.status === 409) throw new VersionConflict(resp);
doc._storeVersion(resp._version);
doc.id(resp._id);
@ -85,7 +85,7 @@ export default function (Promise, Private, es, esAdmin, kbnIndex) {
})
.catch(function (err) {
// cast the error
throw new errors.RequestFailure(err);
throw new RequestFailure(err);
});
};
}

View file

@ -12,7 +12,7 @@
import angular from 'angular';
import _ from 'lodash';
import errors from 'ui/errors';
import { SavedObjectNotFound } from 'ui/errors';
import uuid from 'node-uuid';
import MappingSetupProvider from 'ui/utils/mapping_setup';
@ -211,7 +211,7 @@ export default function SavedObjectFactory(esAdmin, kbnIndex, Promise, Private,
this.applyESResp = (resp) => {
this._source = _.cloneDeep(resp._source);
if (resp.found != null && !resp.found) throw new errors.SavedObjectNotFound(esType, this.id);
if (resp.found != null && !resp.found) throw new SavedObjectNotFound(esType, this.id);
const meta = resp._source.kibanaSavedObjectMeta || {};
delete resp._source.kibanaSavedObjectMeta;

View file

@ -1,229 +1,226 @@
import _ from 'lodash';
import angular from 'angular';
import _ from 'lodash';
const canStack = (function () {
const err = new Error();
return !!err.stack;
}());
const errors = {};
// abstract error class
function KbnError(msg, constructor) {
this.message = msg;
export class KbnError {
constructor(msg, constructor) {
this.message = msg;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, constructor || KbnError);
} else if (canStack) {
this.stack = (new Error()).stack;
} else {
this.stack = '';
}
}
Error.call(this, this.message);
if (Error.captureStackTrace) {
Error.captureStackTrace(this, constructor || KbnError);
} else if (canStack) {
this.stack = (new Error()).stack;
} else {
this.stack = '';
/**
* If the error permits, propagate the error to be rendered on screen
*/
displayToScreen() {
throw this;
}
}
errors.KbnError = KbnError;
// Note, you can't extend the built in Error class:
// http://stackoverflow.com/questions/33870684/why-doesnt-instanceof-work-on-instances-of-error-subclasses-under-babel-node
// Hence we are inheriting from it this way, instead of using extends Error, and this will then preserve
// instanceof checks.
_.class(KbnError).inherits(Error);
/**
* If the error permits, propagate the error to be rendered on screen
* @param handler the handlers that can render the error message to the screen.
*/
KbnError.prototype.displayToScreen = function () {
throw this;
};
/**
* HastyRefresh error class
* @param {String} [msg] - An error message that will probably end up in a log.
*/
errors.HastyRefresh = function HastyRefresh() {
KbnError.call(this,
'Courier attempted to start a query before the previous had finished.',
errors.HastyRefresh);
};
_.class(errors.HastyRefresh).inherits(KbnError);
/**
* SearchTimeout error class
*/
errors.SearchTimeout = function SearchTimeout() {
KbnError.call(this,
'All or part of your request has timed out. The data shown may be incomplete.',
errors.SearchTimeout);
};
_.class(errors.SearchTimeout).inherits(KbnError);
export class SearchTimeout extends KbnError {
constructor() {
super('All or part of your request has timed out. The data shown may be incomplete.',
SearchTimeout);
}
}
/**
* Request Failure - When an entire mutli request fails
* @param {Error} err - the Error that came back
* @param {Object} resp - optional HTTP response
*/
errors.RequestFailure = function RequestFailure(err, resp) {
err = err || false;
export class RequestFailure extends KbnError {
constructor(err, resp) {
err = err || false;
super('Request to Elasticsearch failed: ' + angular.toJson(resp || err.message),
RequestFailure);
KbnError.call(this,
'Request to Elasticsearch failed: ' + angular.toJson(resp || err.message),
errors.RequestFailure);
this.origError = err;
this.resp = resp;
};
_.class(errors.RequestFailure).inherits(KbnError);
this.origError = err;
this.resp = resp;
}
}
/**
* FetchFailure Error - when there is an error getting a doc or search within
* a multi-response response body
* @param {String} [msg] - An error message that will probably end up in a log.
* @param {Object} resp - The response from es.
*/
errors.FetchFailure = function FetchFailure(resp) {
KbnError.call(this,
'Failed to get the doc: ' + angular.toJson(resp),
errors.FetchFailure);
export class FetchFailure extends KbnError {
constructor(resp) {
super(
'Failed to get the doc: ' + angular.toJson(resp),
FetchFailure);
this.resp = resp;
};
_.class(errors.FetchFailure).inherits(KbnError);
this.resp = resp;
}
}
/**
* ShardFailure Error - when one or more shards fail
* @param {String} [msg] - An error message that will probably end up in a log.
* @param {Object} resp - The response from es.
*/
errors.ShardFailure = function ShardFailure(resp) {
KbnError.call(this, resp._shards.failed + ' of ' + resp._shards.total + ' shards failed.',
errors.ShardFailure);
this.resp = resp;
};
_.class(errors.ShardFailure).inherits(KbnError);
export class ShardFailure extends KbnError {
constructor(resp) {
super(
resp._shards.failed + ' of ' + resp._shards.total + ' shards failed.',
ShardFailure);
this.resp = resp;
}
}
/**
* A doc was re-indexed but it was out of date.
* @param {Object} resp - The response from es (one of the multi-response responses).
*/
errors.VersionConflict = function VersionConflict(resp) {
KbnError.call(this,
'Failed to store document changes do to a version conflict.',
errors.VersionConflict);
this.resp = resp;
};
_.class(errors.VersionConflict).inherits(KbnError);
export class VersionConflict extends KbnError {
constructor(resp) {
super(
'Failed to store document changes do to a version conflict.',
VersionConflict);
this.resp = resp;
}
}
/**
* there was a conflict storing a doc
* @param {String} field - the fields which contains the conflict
*/
errors.MappingConflict = function MappingConflict(field) {
KbnError.call(this,
'Field "' + field + '" is defined with at least two different types in indices matching the pattern',
errors.MappingConflict);
};
_.class(errors.MappingConflict).inherits(KbnError);
export class MappingConflict extends KbnError {
constructor(field) {
super(
'Field "' + field + '" is defined with at least two different types in indices matching the pattern',
MappingConflict);
}
}
/**
* a field mapping was using a restricted fields name
* @param {String} field - the fields which contains the conflict
*/
errors.RestrictedMapping = function RestrictedMapping(field, index) {
let msg = field + ' is a restricted field name';
if (index) msg += ', found it while attempting to fetch mapping for index pattern: ' + index;
export class RestrictedMapping extends KbnError {
constructor(field, index) {
let msg = field + ' is a restricted field name';
if (index) msg += ', found it while attempting to fetch mapping for index pattern: ' + index;
KbnError.call(this, msg, errors.RestrictedMapping);
};
_.class(errors.RestrictedMapping).inherits(KbnError);
super(msg, RestrictedMapping);
}
}
/**
* a non-critical cache write to elasticseach failed
*/
errors.CacheWriteFailure = function CacheWriteFailure() {
KbnError.call(this,
'A Elasticsearch cache write has failed.',
errors.CacheWriteFailure);
};
_.class(errors.CacheWriteFailure).inherits(KbnError);
export class CacheWriteFailure extends KbnError {
constructor() {
super(
'A Elasticsearch cache write has failed.',
CacheWriteFailure);
}
}
/**
* when a field mapping is requested for an unknown field
* @param {String} name - the field name
*/
errors.FieldNotFoundInCache = function FieldNotFoundInCache(name) {
KbnError.call(this,
'The ' + name + ' field was not found in the cached mappings',
errors.FieldNotFoundInCache);
};
_.class(errors.FieldNotFoundInCache).inherits(KbnError);
export class FieldNotFoundInCache extends KbnError {
constructor(name) {
super(
'The ' + name + ' field was not found in the cached mappings',
FieldNotFoundInCache);
}
}
/**
* when a mapping already exists for a field the user is attempting to add
* @param {String} name - the field name
*/
errors.DuplicateField = function DuplicateField(name) {
KbnError.call(this,
'The "' + name + '" field already exists in this mapping',
errors.DuplicateField);
};
_.class(errors.DuplicateField).inherits(KbnError);
export class DuplicateField extends KbnError {
constructor(name) {
super(
'The "' + name + '" field already exists in this mapping',
DuplicateField);
}
}
/**
* A saved object was not found
* @param {String} field - the fields which contains the conflict
*/
errors.SavedObjectNotFound = function SavedObjectNotFound(type, id) {
this.savedObjectType = type;
this.savedObjectId = id;
const idMsg = id ? ' (id: ' + id + ')' : '';
KbnError.call(this,
'Could not locate that ' + type + idMsg,
errors.SavedObjectNotFound);
};
_.class(errors.SavedObjectNotFound).inherits(KbnError);
export class SavedObjectNotFound extends KbnError {
constructor(type, id) {
const idMsg = id ? ' (id: ' + id + ')' : '';
super(
'Could not locate that ' + type + idMsg,
SavedObjectNotFound);
this.savedObjectType = type;
this.savedObjectId = id;
}
}
/**
* Tried to call a method that relies on SearchSource having an indexPattern assigned
*/
errors.IndexPatternMissingIndices = function IndexPatternMissingIndices() {
KbnError.call(this,
'IndexPattern\'s configured pattern does not match any indices',
errors.IndexPatternMissingIndices);
};
_.class(errors.IndexPatternMissingIndices).inherits(KbnError);
export class IndexPatternMissingIndices extends KbnError {
constructor() {
super(
'IndexPattern\'s configured pattern does not match any indices',
IndexPatternMissingIndices);
}
}
/**
* Tried to call a method that relies on SearchSource having an indexPattern assigned
*/
errors.NoDefinedIndexPatterns = function NoDefinedIndexPatterns() {
KbnError.call(this,
'Define at least one index pattern to continue',
errors.NoDefinedIndexPatterns);
};
_.class(errors.NoDefinedIndexPatterns).inherits(KbnError);
export class NoDefinedIndexPatterns extends KbnError {
constructor() {
super(
'Define at least one index pattern to continue',
NoDefinedIndexPatterns);
}
}
/**
* Tried to load a route besides management/kibana/index but you don't have a default index pattern!
*/
errors.NoDefaultIndexPattern = function NoDefaultIndexPattern() {
KbnError.call(this,
'Please specify a default index pattern',
errors.NoDefaultIndexPattern);
};
_.class(errors.NoDefaultIndexPattern).inherits(KbnError);
errors.PersistedStateError = function PersistedStateError() {
KbnError.call(this,
'This container is too small to render the visualization',
errors.ContainerTooSmall);
};
_.class(errors.PersistedStateError).inherits(KbnError);
export class NoDefaultIndexPattern extends KbnError {
constructor() {
super(
'Please specify a default index pattern',
NoDefaultIndexPattern);
}
}
export class PersistedStateError extends KbnError {
constructor() {
super(
'Error with the persisted state',
PersistedStateError);
}
}
/**
* UI Errors
*/
errors.VislibError = class VislibError extends KbnError {
export class VislibError extends KbnError {
constructor(message) {
super(message);
}
@ -231,62 +228,51 @@ errors.VislibError = class VislibError extends KbnError {
displayToScreen(handler) {
handler.error(this.message);
}
};
}
errors.ContainerTooSmall = class ContainerTooSmall extends errors.VislibError {
export class ContainerTooSmall extends VislibError {
constructor() {
super('This container is too small to render the visualization');
}
};
}
errors.InvalidWiggleSelection = class InvalidWiggleSelection extends errors.VislibError {
export class InvalidWiggleSelection extends VislibError {
constructor() {
super('In wiggle mode the area chart requires ordered values on the x-axis. Try using a Histogram or Date Histogram aggregation.');
}
};
}
errors.PieContainsAllZeros = class PieContainsAllZeros extends errors.VislibError {
export class PieContainsAllZeros extends VislibError {
constructor() {
super('No results displayed because all values equal 0.');
}
};
}
errors.InvalidLogScaleValues = class InvalidLogScaleValues extends errors.VislibError {
export class InvalidLogScaleValues extends VislibError {
constructor() {
super('Values less than 1 cannot be displayed on a log scale');
}
};
}
errors.StackedBarChartConfig = class StackedBarChartConfig extends errors.VislibError {
export class StackedBarChartConfig extends VislibError {
constructor(message) {
super(message);
}
};
}
/**
* error thrown when user tries to render an chart with less
* than the required number of data points
* @param {String} message - the message to provide with the error
*/
errors.NotEnoughData = class NotEnoughData extends errors.VislibError {
export class NotEnoughData extends VislibError {
constructor(message) {
super(message);
}
};
}
errors.NoResults = class NoResults extends errors.VislibError {
export class NoResults extends VislibError {
constructor() {
super('No results found');
}
};
export default errors;
}

View file

@ -3,7 +3,7 @@ import sinon from 'auto-release-sinon';
import ngMock from 'ng_mock';
import expect from 'expect.js';
import Promise from 'bluebird';
import errors from 'ui/errors';
import { DuplicateField } from 'ui/errors';
import IndexedArray from 'ui/indexed_array';
import FixturesLogstashFieldsProvider from 'fixtures/logstash_fields';
import FixturesStubbedDocSourceResponseProvider from 'fixtures/stubbed_doc_source_response';
@ -255,7 +255,7 @@ describe('index pattern', function () {
expect(function () {
indexPattern.addScriptedField(scriptedField.name, '\'new script\'', 'string');
}).to.throwError(function (e) {
expect(e).to.be.a(errors.DuplicateField);
expect(e).to.be.a(DuplicateField);
});
});
});

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import errors from 'ui/errors';
import { SavedObjectNotFound, DuplicateField } from 'ui/errors';
import angular from 'angular';
import getComputedFields from 'ui/index_patterns/_get_computed_fields';
import formatHit from 'ui/index_patterns/_format_hit';
@ -69,7 +69,7 @@ export default function IndexPatternFactory(Private, Notifier, config, kbnIndex,
function updateFromElasticSearch(indexPattern, response) {
if (!response.found) {
throw new errors.SavedObjectNotFound(type, indexPattern.id);
throw new SavedObjectNotFound(type, indexPattern.id);
}
_.forOwn(mapping, (fieldMapping, name) => {
@ -212,7 +212,7 @@ export default function IndexPatternFactory(Private, Notifier, config, kbnIndex,
const names = _.pluck(scriptedFields, 'name');
if (_.contains(names, name)) {
throw new errors.DuplicateField(name);
throw new DuplicateField(name);
}
this.fields.push({

View file

@ -1,5 +1,5 @@
import 'ui/filters/short_dots';
import errors from 'ui/errors';
import { IndexPatternMissingIndices } from 'ui/errors';
import IndexPatternsIndexPatternProvider from 'ui/index_patterns/_index_pattern';
import IndexPatternsPatternCacheProvider from 'ui/index_patterns/_pattern_cache';
import IndexPatternsGetIdsProvider from 'ui/index_patterns/_get_ids';
@ -39,7 +39,7 @@ function IndexPatternsProvider(esAdmin, Notifier, Private, Promise, kbnIndex) {
};
self.errors = {
MissingIndices: errors.IndexPatternMissingIndices
MissingIndices: IndexPatternMissingIndices
};
self.cache = patternCache;

View file

@ -3,7 +3,7 @@ import sinon from 'auto-release-sinon';
import noDigestPromises from 'test_utils/no_digest_promises';
import ngMock from 'ng_mock';
import expect from 'expect.js';
import errors from 'ui/errors';
import { PersistedStateError } from 'ui/errors';
import 'ui/persisted_state';
let PersistedState;
@ -62,7 +62,7 @@ describe('Persisted State Provider', function () {
};
expect(run).to.throwException(function (err) {
expect(err).to.be.a(errors.PersistedStateError);
expect(err).to.be.a(PersistedStateError);
});
});
@ -86,7 +86,7 @@ describe('Persisted State Provider', function () {
};
expect(run).to.throwException(function (err) {
expect(err).to.be.a(errors.PersistedStateError);
expect(err).to.be.a(PersistedStateError);
});
});
@ -100,7 +100,7 @@ describe('Persisted State Provider', function () {
};
expect(run).to.throwException(function (err) {
expect(err).to.be.a(errors.PersistedStateError);
expect(err).to.be.a(PersistedStateError);
});
});
});

View file

@ -6,7 +6,7 @@
import _ from 'lodash';
import toPath from 'lodash/internal/toPath';
import errors from 'ui/errors';
import { PersistedStateError } from 'ui/errors';
import SimpleEmitter from 'ui/utils/simple_emitter';
function prepSetParams(key, value, path) {
@ -54,13 +54,13 @@ export class PersistedState {
// Some validations
if (this._parent) {
if (this._path.length <= 0) {
throw new errors.PersistedStateError('PersistedState child objects must contain a path');
throw new PersistedStateError('PersistedState child objects must contain a path');
}
if (!(this._parent instanceof PersistedState)) {
throw new errors.PersistedStateError('Parent object must be an instance of PersistedState');
throw new PersistedStateError('Parent object must be an instance of PersistedState');
}
} else if (!this._path.length && value && !_.isPlainObject(value)) {
throw new errors.PersistedStateError('State value must be a plain object');
throw new PersistedStateError('State value must be a plain object');
}
value = value || this._getDefault();

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import errors from 'ui/errors';
import { ContainerTooSmall } from 'ui/errors';
export default function ErrorHandlerFactory() {
@ -28,7 +28,7 @@ export default function ErrorHandlerFactory() {
const badHeight = _.isNaN(height) || height <= 0;
if (badWidth || badHeight) {
throw new errors.ContainerTooSmall();
throw new ContainerTooSmall();
}
}
}

View file

@ -6,7 +6,7 @@ import AxisTitleProvider from './axis_title';
import AxisLabelsProvider from './axis_labels';
import AxisScaleProvider from './axis_scale';
import AxisConfigProvider from './axis_config';
import errors from 'ui/errors';
import { VislibError } from 'ui/errors';
export default function AxisFactory(Private) {
const ErrorHandler = Private(ErrorHandlerProvider);
@ -162,7 +162,7 @@ export default function AxisFactory(Private) {
validate() {
if (this.axisConfig.isLogScale() && this.axisConfig.isPercentage()) {
throw new errors.VislibError(`Can't mix percentage mode with log scale.`);
throw new VislibError(`Can't mix percentage mode with log scale.`);
}
}

View file

@ -1,7 +1,7 @@
import d3 from 'd3';
import _ from 'lodash';
import moment from 'moment';
import errors from 'ui/errors';
import { InvalidLogScaleValues } from 'ui/errors';
export default function AxisScaleFactory() {
class AxisScale {
@ -148,7 +148,7 @@ export default function AxisScaleFactory() {
}
throwLogScaleValuesError() {
throw new errors.InvalidLogScaleValues();
throw new InvalidLogScaleValues();
}
logDomain(min, max) {

View file

@ -1,7 +1,7 @@
import d3 from 'd3';
import _ from 'lodash';
import $ from 'jquery';
import errors from 'ui/errors';
import { NoResults } from 'ui/errors';
import Binder from 'ui/binder';
import VislibLibLayoutLayoutProvider from './layout/layout';
import VislibLibChartTitleProvider from './chart_title';
@ -104,7 +104,7 @@ export default function HandlerBaseClass(Private) {
const dataType = this.data.type;
if (!dataType) {
throw new errors.NoResults();
throw new NoResults();
}
}

View file

@ -1,7 +1,7 @@
import _ from 'lodash';
import d3 from 'd3';
import Binder from 'ui/binder';
import errors from 'ui/errors';
import { KbnError } from 'ui/errors';
import EventsProvider from 'ui/events';
import './styles/main.less';
import VislibLibResizeCheckerProvider from './lib/resize_checker';
@ -110,7 +110,7 @@ export default function VisFactory(Private) {
this.handler[method]();
} catch (error) {
if (error instanceof errors.KbnError) {
if (error instanceof KbnError) {
error.displayToScreen(this.handler);
} else {
throw error;

View file

@ -1,7 +1,7 @@
import d3 from 'd3';
import _ from 'lodash';
import $ from 'jquery';
import errors from 'ui/errors';
import { PieContainsAllZeros, ContainerTooSmall } from 'ui/errors';
import VislibVisualizationsChartProvider from './_chart';
export default function PieChartFactory(Private) {
@ -46,7 +46,7 @@ export default function PieChartFactory(Private) {
});
if (isAllZeros) {
throw new errors.PieContainsAllZeros();
throw new PieContainsAllZeros();
}
}
@ -176,7 +176,7 @@ export default function PieChartFactory(Private) {
const minHeight = 20;
if (width <= minWidth || height <= minHeight) {
throw new errors.ContainerTooSmall();
throw new ContainerTooSmall();
}
}

View file

@ -1,7 +1,7 @@
import d3 from 'd3';
import _ from 'lodash';
import $ from 'jquery';
import errors from 'ui/errors';
import { ContainerTooSmall } from 'ui/errors';
import TooltipProvider from 'ui/vis/components/tooltip';
import VislibVisualizationsChartProvider from './_chart';
import VislibVisualizationsTimeMarkerProvider from './time_marker';
@ -214,7 +214,7 @@ export default function PointSeriesFactory(Private) {
const el = this;
if (width < minWidth || height < minHeight) {
throw new errors.ContainerTooSmall();
throw new ContainerTooSmall();
}
if (addTimeMarker) {

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import errors from 'ui/errors';
import { InvalidLogScaleValues, NotEnoughData } from 'ui/errors';
export default function PointSeriesProvider() {
@ -17,7 +17,7 @@ export default function PointSeriesProvider() {
validateDataCompliesWithScalingMethod(data) {
const invalidLogScale = data.values && data.values.some(d => d.y < 1);
if (this.getValueAxis().axisConfig.isLogScale() && invalidLogScale) {
throw new errors.InvalidLogScaleValues();
throw new InvalidLogScaleValues();
}
}
@ -96,7 +96,7 @@ export default function PointSeriesProvider() {
const notEnoughData = this.chartData.values.length < 2;
if (notEnoughData) {
throw new errors.NotEnoughData(message);
throw new NotEnoughData(message);
}
}
}

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import errors from 'ui/errors';
import { ContainerTooSmall } from 'ui/errors';
import VislibVisualizationsPointSeriesProvider from './_point_series';
export default function ColumnChartFactory(Private) {
@ -187,7 +187,7 @@ export default function ColumnChartFactory(Private) {
function widthFunc() {
if (barWidth < minWidth) {
throw new errors.ContainerTooSmall();
throw new ContainerTooSmall();
}
if (isTimeScale) {

View file

@ -221,9 +221,8 @@ export default class DashboardPage {
}
clickDashboardByLinkText(dashName) {
return this.findTimeout
.findByLinkText(dashName)
.click();
PageObjects.common.debug('clickDashboardByLinkText: ' + dashName);
return PageObjects.common.try(() => this.findTimeout.findByLinkText(dashName).click());
}
async searchForDashboardWithName(dashName) {