From 5c48511052b8603b7077780e22f893f4c0160c74 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 3 Jan 2024 20:34:28 -0400 Subject: validators: validateProperties: nest in a cause layer --- src/data/things/validators.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/data/things/validators.js b/src/data/things/validators.js index c15a6cc7..a212b8ae 100644 --- a/src/data/things/validators.js +++ b/src/data/things/validators.js @@ -374,9 +374,11 @@ export function validateProperties(spec) { const value = object[specKey]; try { specValidator(value); - } catch (error) { - error.message = `(key: ${colors.green(specKey)}, value: ${inspect(value)}) ${error.message}`; - push(error); + } catch (caughtError) { + const keyPart = colors.green(specKey); + const valuePart = inspect(value); + const message = `Error for key ${keyPart}: ${valuePart}`; + push(new Error(message, {cause: caughtError})); } } -- cgit 1.3.0-6-gf8a5