Skip to content

Commit

Permalink
Always throw error objects - never strings (#171498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Watson authored Nov 20, 2023
1 parent 9523a78 commit 4f9094c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion preinstall_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}`);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/api_integration/apis/maps/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 4f9094c

Please sign in to comment.