From 39c553661b354a7cddc8de80315dd99337f1dde2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 6 Jan 2024 09:23:14 -0400 Subject: data, yaml: match Error constructors more closely when extending --- src/data/yaml.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/data/yaml.js') diff --git a/src/data/yaml.js b/src/data/yaml.js index caf414e5..72e212b9 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -262,12 +262,14 @@ function makeProcessDocument( thing[property] = value; } catch (caughtError) { skippedFields.add(field); - fieldValueErrors.push(new FieldValueError(field, value, caughtError)); + fieldValueErrors.push(new FieldValueError( + field, value, {cause: caughtError})); } } if (!empty(fieldValueErrors)) { - aggregate.push(new FieldValueAggregateError(thingConstructor, fieldValueErrors)); + aggregate.push(new FieldValueAggregateError( + fieldValueErrors, thingConstructor)); } if (skippedFields.size >= 1) { @@ -335,7 +337,7 @@ export class FieldCombinationError extends Error { export class FieldValueAggregateError extends AggregateError { [Symbol.for('hsmusic.aggregate.translucent')] = true; - constructor(thingConstructor, errors) { + constructor(errors, thingConstructor) { const constructorText = colors.green(thingConstructor.name); @@ -346,7 +348,7 @@ export class FieldValueAggregateError extends AggregateError { } export class FieldValueError extends Error { - constructor(field, value, cause) { + constructor(field, value, options) { const fieldText = colors.green(`"${field}"`); @@ -355,7 +357,7 @@ export class FieldValueError extends Error { super( `Failed to set ${fieldText} field to ${valueText}`, - {cause}); + options); } } -- cgit 1.3.0-6-gf8a5