Skip to content

Commit

Permalink
[8.11] Always throw error objects - never strings (#171498) (#171547)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.11`:
- [Always throw error objects - never strings
(#171498)](#171498)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Thomas
Watson","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-11-20T14:23:16Z","message":"Always
throw error objects - never strings
(#171498)","sha":"4f9094caf3cc4781137b7cfccbe2e1858f4f39c0","branchLabelMapping":{"^v8.12.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","v8.12.0"],"number":171498,"url":"https://github.com/elastic/kibana/pull/171498","mergeCommit":{"message":"Always
throw error objects - never strings
(#171498)","sha":"4f9094caf3cc4781137b7cfccbe2e1858f4f39c0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.12.0","labelRegex":"^v8.12.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/171498","number":171498,"mergeCommit":{"message":"Always
throw error objects - never strings
(#171498)","sha":"4f9094caf3cc4781137b7cfccbe2e1858f4f39c0"}}]}]
BACKPORT-->

Co-authored-by: Thomas Watson <[email protected]>
  • Loading branch information
kibanamachine and Thomas Watson authored Nov 20, 2023
1 parent 2581292 commit dbf0760
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 dbf0760

Please sign in to comment.