mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Don't mutate error message (#58452)
* fix: 🐛 don't mutate error object in-place This avoids mutating error thrown by an expression function in-place. The error might not even be an object, in which case mutating it will throw. * test: 💍 capture in test that thrown error is not mutated Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
afb5d8fa58
commit
db05fb6738
2 changed files with 2 additions and 1 deletions
|
@ -630,6 +630,7 @@ describe('Execution', () => {
|
|||
},
|
||||
});
|
||||
expect(node2.debug?.rawError).toBeInstanceOf(Error);
|
||||
expect(node2.debug?.rawError).toEqual(new Error('foo'));
|
||||
});
|
||||
|
||||
test('sets .debug object to expected shape', async () => {
|
||||
|
|
|
@ -230,8 +230,8 @@ export class Execution<
|
|||
input = output;
|
||||
} catch (rawError) {
|
||||
const timeEnd: number = this.params.debug ? performance.now() : 0;
|
||||
rawError.message = `[${fnName}] > ${rawError.message}`;
|
||||
const error = createError(rawError) as ExpressionValueError;
|
||||
error.error.message = `[${fnName}] > ${error.error.message}`;
|
||||
|
||||
if (this.params.debug) {
|
||||
(link as ExpressionAstFunction).debug = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue