Always throw error objects - never strings (#171498)

This commit is contained in:
Thomas Watson 2023-11-20 15:23:16 +01:00 committed by GitHub
parent 9523a78e7a
commit 4f9094caf3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 4 deletions

View file

@ -10,7 +10,7 @@
const isUsingNpm = process.env.npm_config_git !== undefined;
if (isUsingNpm) {
throw `Use Yarn instead of npm, see Kibana's contributing guidelines`;
throw new Error(`Use Yarn instead of npm, see Kibana's contributing guidelines`);
}
// The value of the `npm_config_argv` env for each command:

View file

@ -266,7 +266,7 @@ function compileCondition(description, compiledObject) {
return new RegExp(description.lines_regex, 'm').test(lines);
}, compiledObject);
} else {
throw 'unknown condition type - got: ' + JSON.stringify(description);
throw new Error(`unknown condition type - got: ${JSON.stringify(description)}`);
}
}

View file

@ -177,7 +177,7 @@ export class ExplorerChartDistribution extends React.Component {
.rangePoints([rowMargin, chartHeight - rowMargin])
.domain(scaleCategories);
} else {
throw `chartType '${chartType}' not supported`;
throw new Error(`chartType '${chartType}' not supported`);
}
const yAxis = d3.svg

View file

@ -75,7 +75,7 @@ export default function ({ getService }) {
try {
panels = JSON.parse(resp.body.attributes.panelsJSON);
} catch (error) {
throw 'Unable to parse panelsJSON from dashboard saved object';
throw new Error('Unable to parse panelsJSON from dashboard saved object');
}
expect(panels.length).to.be(1);
expect(panels[0].type).to.be('map');